Forum Discussion

Gestcoaubin's avatar
Gestcoaubin
Copper Contributor
Sep 13, 2021

several tabs grouped together in a different file and updated automatically

Hello, I have several datasheets with a single tab each that I would like to see grouped into a master file where the data would be updated automatically.   Basically, on my computer in each folder...
  • Juliano-Petrukio's avatar
    Sep 13, 2021

    Gestcoaubin 

    To be honest, I would suggest you use power query

    But as you mentioned, you want to check the content of each file ("tab") on a master file.

    There is a manual way, but I guess you can play with vba coding.

    Ps.: For your safety, make a Copy of the original folder before you run the code below.

     

    Sub ConslidateWorkbooks()
        
        Dim FolderPath As String
        Dim Filename As String
        Dim Sheet As Worksheet
        Application.ScreenUpdating = False
        FolderPath = Environ("userprofile") & "DesktopTest"
        Filename = Dir(FolderPath & "*.xls*")
        Do While Filename <> ""
            Workbooks.Open Filename:=FolderPath & Filename, ReadOnly:=True
            For Each Sheet In ActiveWorkbook.Sheets
                Sheet.Copy After:=ThisWorkbook.Sheets(1)
            Next Sheet
            Workbooks(Filename).Close
            Filename = Dir()
        Loop
        Application.ScreenUpdating = True
    End Sub

     

     

Resources