Results 1 to 19 of 19

Merging multiple workbooks that contain identical tabs

Threaded View

  1. #1
    Registered User
    Join Date
    03-17-2011
    Location
    toronto
    MS-Off Ver
    Excel 2003
    Posts
    11

    Merging multiple workbooks that contain identical tabs

    I have multiple workbooks, all located in the same folder, and I want to merge them into a singular workbook. Each workbook contains 22 worksheets and each workbook have identical worksheet names. Each tab has a header that fills rows 1 through 5 after which the data starts. There is no naming convention for the workbooks as each come from seperate employees who name them what they will, but the template within thet workbooks remains the same.

    I found the following code which is able to bring the workbooks together and recognize when two worksheets share the same name but instead of merging the two worksheets into one it appends a (2),(3), etc. when duplicate worksheet names are detected.

    What I want to be able to do is select which workbooks I want to combine and then have the workbooks combine and have all the tabs that share names combine into a singular tabs.

    If what I am asking is impossible or if I am being anyway unclear in what I am asking please let me know and I will attempt to clarify. I can upload a copy of the workbook I am trying to merge together if that helps.

    here is the code i found previously:

    Sub CombineWorkbooks()
        Dim FilesToOpen
        Dim x As Integer
    
        On Error GoTo ErrHandler
        Application.ScreenUpdating = False
    
        FilesToOpen = Application.GetOpenFilename _
          (FileFilter:="Microsoft Excel Files (*.xls), *.xls", _
          MultiSelect:=True, Title:="Files to Merge")
    
        If TypeName(FilesToOpen) = "Boolean" Then
            MsgBox "No Files were selected"
            GoTo ExitHandler
        End If
    
        x = 1
        While x <= UBound(FilesToOpen)
            Workbooks.Open FileName:=FilesToOpen(x)
            Sheets().Move After:=ThisWorkbook.Sheets _
              (ThisWorkbook.Sheets.Count)
            x = x + 1
        Wend
    
    ExitHandler:
        Application.ScreenUpdating = True
        Exit Sub
    
    ErrHandler:
        MsgBox Err.Description
        Resume ExitHandler
    End Sub
    Thanks in advance!
    Last edited by glurbly; 03-18-2011 at 01:09 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1