当前位置:网站首页>Excel vba: saving multiple worksheets as new files

Excel vba: saving multiple worksheets as new files

2022-07-26 05:03:00 Avasla

Sub  create a file ()

' Define the name of the text file 
Dim file As String, arr, i

' Specify the name of the text file 
file = ThisWorkbook.Path & "\ File name to be copied .xlsx"

' Hereunder Array List the names of all worksheets that need to be copied 
Worksheets(Array("sheet1", "sheet2", "sheet3")).Copy
 
Set wbNew = ActiveWorkbook
 
With wbNew
 
    ActiveWorkbook.SaveAs Filename:=file .Close
 
End With
 
End Sub

原网站

版权声明
本文为[Avasla]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/207/202207260457266927.html