• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help! trying to consolidate multiple workbook to single workbook

it_help

New Member
1. There are 26 workbooks with 13 sheets in it. All the workbooks has same tabs and same columns but different data.
2. I am trying to consolidate 8 out of 13 sheets into one master workbook for some data gathering purposes.
3. My expectation is to create one master workbook which contains all the 8 required sheets and each sheet should contain data for all the 26 workbooks. Also, these workbooks are password protected. For example: if there are 3 sheets in 10 workbook : Travel , rent and training. Now i want to get travel data for all the 10 workbooks in one sheet and same for rent and training. basically it should merge all the tabs with same name in the master workbook

I have tried a VBA, it is consolidating all the files but not merging the data of the sheets with the same name. It is just bringing in all the sheets together in one workbook

Code:
Sub GetSheets()
'Update ExcelJunction.com
   
    Path = ""
    Filename = Dir(Path & "*.xlsx")
    Do While Filename <> ""
    Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
   
    For Each Workbook In Workbooks
       If Workbook.Name <> ThisWorkbook.Name Then
    Workbook.Worksheets(1).Copy Before:=ThisWorkbook.Sheets(1)
    ActiveSheet.Name = Workbook.Name
    End If
    Next
    Set Workbook = Nothing
    Workbooks(Filename).Close
    Filename = Dir()
    Loop
End Sub

Hope this make some sense.

Please let me know any additional details are required.

Thanks!
 

Attachments

  • Capture.PNG
    Capture.PNG
    52.8 KB · Views: 11
Last edited by a moderator:
Back
Top