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
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
5,244 questions
Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
2,005 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,052 questions
{count} votes

Your answer

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