我试图将数据从另一个工作簿中的多个工作表复制到当前工作表并遇到
运行时错误1004
“ Range类的复制方法失败”
错误发生在:
Rows(j).Copy _
(thisws.Range("A300000").End(xlUp).Offset(1,0)
感谢我的帮助,因为我是Excel VBA的新手。
Sub copyEPOSaging()
Dim strUserFile As String
Dim thiswb As Workbook
Dim wb As Workbook
Dim thisws As Worksheet
Dim ws As Worksheet
Set thiswb = ThisWorkbook
Set thisws = thiswb.Sheets("ePOS")
'Opening File dialog box
Application.FileDialog(msoFileDialogFilePicker).Show
'assign variable to identify selected file using dialog box
strUserFile = Application.FileDialog(msoFileDialogFilePicker).SelectedItems(1)
'open the selected file
Set wb = Workbooks.Open(strUserFile)
Dim i As Integer, j As Integer, k As Integer
Dim lastRow As Integer
For i = 1 To Sheets.Count - 1
With wb.Sheets(i)
lastRow = Range("A200000").End(xlUp).Row
For j = 3 To lastRow
Rows(j).Copy _
(thisws.Range("A300000").End(xlUp).Offset(1, 0))
Next j
End With
Next i
MsgBox "Done"
End Sub