下面的代码我正在从多个工作表中获取数据到主工作簿中。 运行宏时,出现错误:没有下一步的情况。
Sub copydata()
Dim FolderPath As String, Filepath As String, Filename As String
FolderPath = "C:\Users\stefan.georgescu\Desktop\Verificari\"
Filepath = FolderPath & "*.xlsx"
Filename = Dir(Filepath)
Dim erow As Long, lastrow As Long, lastcolumn As Long
Do While Filename <> ""
Dim wb As Workbook
Set wb = Workbooks.Open(FolderPath & Filename)
Do
For counter = 1 To 5
Dim ws As Worksheet
Set wb = ActiveWorkbook
Do
For Each ws In wb.Worksheets
wb.Worksheets(counter).Activate
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
lastcolumn = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
Range(Cells(2, 1), Cells(lastrow, lastcolumn)).Copy
'Sheets(“Sheet1”).Select
Workbooks("VerificariCEgeneral.xlsm").Worksheets(counter).Activate
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 1).Select
ActiveSheet.Paste
Next
wb.Close savechanges:=False
Filename = Dir
Loop
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 1).Select
End Sub