Combining multiple excel workbooks into one

Trevor Johnson 0 Reputation points
2023-11-13T19:10:42.7733333+00:00

I am having trouble with a '424' error code with visual basic.

I am trying to combine hundreds of old excel workbooks into one single workbook, that inlcudes all the sheets from each workbook in a folder directory.

Here is the code i am working with. Any chance you can see

Sub GetSheets()

Dim Sheets As Object

Dim ActvieWorkbook As Object

Path = "C:\Users\xxxx\xxxx\xxxx"

Filename = Dir(Path & "*.xls")

Do While Filename <> ""

Workbooks.Open Filename:=Path & Filename, ReadOnly:=True

For Each Sheets In ActvieWorkbook.Sheets()

Sheet.Copy After:=ThisWorkbook.Sheets(1)

Next Sheets

Workbooks(Filename).Close

Filename = Dir()

Loop

End Sub

User's image

User's image

Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Install, redeem, activate | For business | Windows
Microsoft 365 and Office | Excel | For business | Windows
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.