several tabs grouped together in a different file and updated automatically

%3CLINGO-SUB%20id%3D%22lingo-sub-2745836%22%20slang%3D%22en-US%22%3Eseveral%20tabs%20grouped%20together%20in%20a%20different%20file%20and%20updated%20automatically%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2745836%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%20I%20have%20several%20datasheets%20with%20a%20single%20tab%20each%20that%20I%20would%20like%20to%20see%20grouped%20into%20a%20master%20file%20where%20the%20data%20would%20be%20updated%20automatically.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBasically%2C%20on%20my%20computer%20in%20each%20folder%20of%20an%20X%20project%2C%20I%20have%20an%20Excel%20spreadsheet%20that%20lists%20the%20contracts%20and%20invoices%20for%20the%20project.%20But%20I%20would%20like%20to%20have%20a%20general%20file%20on%20my%20desktop%20where%20I%20could%20switch%20from%20one%20tab%20to%20another%20quickly%20in%20order%20to%20validate%20which%20company%20had%20the%20contract%2C%20at%20what%20price%2C%20versus%20which%20competitor%2C%20etc.%2C%20in%20order%20not%20to%20always%20give%20the%20contract%20to%20the%20same%20companies%20you%20see.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20thought%20the%20%22consolidate%22%20command%20would%20be%20the%20right%20one%2C%20but%20it%20just%20seems%20to%20be%20picking%20up%20cells%20when%20I%20want%20the%20entire%20tab.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20the%20tabs%20in%20the%20master%20file%20to%20be%20identical%20to%20the%20reference%20one%20(layout%2C%20sheet%20name%2C%20etc.).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2745836%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2745879%22%20slang%3D%22en-US%22%3ERe%3A%20several%20tabs%20grouped%20together%20in%20a%20different%20file%20and%20updated%20automatically%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2745879%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1154341%22%20target%3D%22_blank%22%3E%40Gestcoaubin%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20be%20honest%2C%20I%20would%20suggest%20you%20use%20power%20query%3C%2FP%3E%3CP%3EBut%20as%20you%20mentioned%2C%20you%20want%20to%20check%20the%20content%20of%20each%20file%20(%22tab%22)%20on%20a%20master%20file.%3C%2FP%3E%3CP%3EThere%20is%20a%20manual%20way%2C%20but%20I%20guess%20you%26nbsp%3Bcan%20play%20with%20vba%20coding.%3C%2FP%3E%3CP%3EPs.%3A%20For%20your%20safety%2C%20make%20a%20Copy%20of%20the%20original%20folder%20before%20you%20run%20the%20code%20below.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-visual-basic%22%3E%3CCODE%3ESub%20ConslidateWorkbooks()%0A%20%20%20%20%0A%20%20%20%20Dim%20FolderPath%20As%20String%0A%20%20%20%20Dim%20Filename%20As%20String%0A%20%20%20%20Dim%20Sheet%20As%20Worksheet%0A%20%20%20%20Application.ScreenUpdating%20%3D%20False%0A%20%20%20%20FolderPath%20%3D%20Environ(%22userprofile%22)%20%26amp%3B%20%22DesktopTest%22%0A%20%20%20%20Filename%20%3D%20Dir(FolderPath%20%26amp%3B%20%22*.xls*%22)%0A%20%20%20%20Do%20While%20Filename%20%26lt%3B%26gt%3B%20%22%22%0A%20%20%20%20%20%20%20%20Workbooks.Open%20Filename%3A%3DFolderPath%20%26amp%3B%20Filename%2C%20ReadOnly%3A%3DTrue%0A%20%20%20%20%20%20%20%20For%20Each%20Sheet%20In%20ActiveWorkbook.Sheets%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheet.Copy%20After%3A%3DThisWorkbook.Sheets(1)%0A%20%20%20%20%20%20%20%20Next%20Sheet%0A%20%20%20%20%20%20%20%20Workbooks(Filename).Close%0A%20%20%20%20%20%20%20%20Filename%20%3D%20Dir()%0A%20%20%20%20Loop%0A%20%20%20%20Application.ScreenUpdating%20%3D%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2745920%22%20slang%3D%22en-US%22%3ERe%3A%20several%20tabs%20grouped%20together%20in%20a%20different%20file%20and%20updated%20automatically%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2745920%22%20slang%3D%22en-US%22%3EThank%20you%20!%20I%20don't%20master%20the%20coding%20very%20well.%20Can%20you%20help%20me%20with%20the%20manual%20way%20%3F%3C%2FLINGO-BODY%3E
New Contributor

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 of an X project, I have an Excel spreadsheet that lists the contracts and invoices for the project. But I would like to have a general file on my desktop where I could switch from one tab to another quickly in order to validate which company had the contract, at what price, versus which competitor, etc., in order not to always give the contract to the same companies you see.

 

I thought the "consolidate" command would be the right one, but it just seems to be picking up cells when I want the entire tab.

 

I want the tabs in the master file to be identical to the reference one (layout, sheet name, etc.).

3 Replies

@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

 

 

Thank you ! I don't master the coding very well. Can you help me with the manual way ?
replace Environ("userprofile") & "DesktopTest" with your folder address
Example:
"C:\Users\luthi\Documents"

FolderPath="C:\Users\luthi\Documents"