AmanBesara
New Member
- Joined
- May 20, 2020
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
Sub GetSheets()
' Write in the specific path where the file is saved in the path
Path = "D:jjjjj\Report 2019-20\"
Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub
This is the following code. I am basically trying to copy multiple excel files in one excel file. My error "Sheet.Copy After:=ThisWorkbook.Sheets(1)" . Can anyone help me debug it?
' Write in the specific path where the file is saved in the path
Path = "D:jjjjj\Report 2019-20\"
Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub
This is the following code. I am basically trying to copy multiple excel files in one excel file. My error "Sheet.Copy After:=ThisWorkbook.Sheets(1)" . Can anyone help me debug it?