Consulting

Results 1 to 2 of 2

Thread: What is the best way to combine multiple workbooks into one?

  1. #1
    VBAX Regular
    Joined
    Nov 2016
    Posts
    15
    Location

    What is the best way to combine multiple workbooks into one?

    Hello,

    As the title says, I'm trying to find the best way to combine information stored in multiple workbooks into a separate one.

    Say that I have Workbook1, Workbook2, Workbook3,..... etc.

    Now I'm trying to build a new workbook called "Combined". In this "Combined" workbook, I want it to load a couple columns from Workbook1.Sheet1 into "Combined".Sheet1.Column A-C, and then some other columns from Workbook2.Sheet1 into "Combined".Sheet1.Column D-E.

    The general idea is this "Combined" workbook take information from different sources and form a new big sheet that serves as a database, which later might feed information to other workbooks.

    I know I can use something as simple as using "=" in a cell that links to a certain cell in another workbook. My concern is if I have larger and growing data later, I will need a better way to link these workbooks, sheets, and columns.

    It will be a great help if you can provide a couple different ways that are available for this kind of task, including VBA if needed.

    Thanks for reading.

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    This code from Jake should do the trick
    Option Explicit
    
    Sub CombineFiles() 
    Dim Path  As String 
    Dim FileName  As String 
    Dim Wkb  As Workbook 
    Dim WS   As Worksheet 
    Application.EnableEvents = False 
    Application.ScreenUpdating = False 
    Path = "C:\" 'Change as needed
    FileName = Dir(Path & "\*.xls", vbNormal) 
    Do Until FileName = "" 
    Set Wkb = Workbooks.Open(FileName:=Path & "\" & FileName) 
    For Each WS In Wkb.Worksheets 
    WS.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count) 
    Next WS 
    Wkb.Close False 
    FileName = Dir() 
    Loop 
    Application.EnableEvents = True 
    Application.ScreenUpdating = True 
    End Sub
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •