Sub test1()
Dim LastRow As Long
Dim LastRow2 As Long
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
If Sheet.Name = "Orders" Then
LastRow = ThisWorkbook.ActiveSheet.Cells(ThisWorkbook.ActiveSheet.Rows.Count, "AK").End(xlUp).Row
Range("AP" & LastRow).Select
Range(Selection, Cells(1)).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.Copy
LastRow2 = Workbooks("Book1").Sheets("Sheet1").Cells(ThisWorkbook.ActiveSheet.Rows.Count, "AK").End(xlUp).Row
Range("A" & LastRow + 1).Select
Selection.Paste
'Sheet.Copy After:=ThisWorkbook.Sheets(1)
End If
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub
以上是我目前的代码。以下是我要完成的任务:
我的问题与此处回答的问题不同:Excel vba: copy sheet and get resulting sheet object?
原因是我不希望复制实际的工作表对象,只复制其内容。