0
我無法修改此代碼以複製關閉工作簿的第一個工作表並將其導入活動工作簿。它希望複製所有工作表,並將「after:= WB.Sheets(WB.Sheets.Count)」添加到工作表中的隨機單元格。 任何幫助,不勝感激。VBA將第一個工作表從關閉工作簿導入到活動工作簿
Dim WB As Workbook
Dim SourceWB As Workbook
Dim WS As Worksheet
Dim ASheet As Worksheet
Application.ScreenUpdating = False
Application.EnableEvents = False
Set WB = ActiveWorkbook
Set ASheet = ActiveSheet
Set SourceWB = Workbooks.Open("C:\Users\ME\Desktop\Book1.xlsx")
For Each WS In SourceWB.Worksheets
WS.Copy after:=WB.Sheets(WB.Sheets.Count)
Next WS
SourceWB.Close savechanges:=False
Set WS = Nothing
Set SourceWB = Nothing
WB.Activate
ASheet.Select
Set ASheet = Nothing
Set WB = Nothing
Application.EnableEvents = True
運行完美。我非常感謝你的幫助! – JKnight