Excel - Combine Multiple Tabs Easily


Our office is using Excel 07. We have 107 tabs with 3 columns of data on each. We need to get all of this data onto 1 tab. Is there an easy way to take care of this?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ProfessorJimJamMicrosoft Excel ExpertCommented:
I can provide you a solution with vba. Is that ok?
WO2015Author Commented:
As long as its something I can understand, I am not familiar with VBA at all.
ProfessorJimJamMicrosoft Excel ExpertCommented:
visual-basic-editor.pnginsert-vba-module.pngOk then,

this is how you put the below code in your workbook which you want to append the worksheets into oneworksheet.

1. Open your workbook in Excel.
2. Press Alt+F11 to open Visual Basic Editor (VBE).

2. Right-click on your workbook name in the "Project-VBAProject" pane (at the top left corner of the editor window) and select Insert -> Module from the context menu

4- Copy the VBA code below and paste it to the right pane of the VBA editor ("Module1" window).



Option Explicit

Sub CopyRangeFromMultiWorksheets()
    Dim sh As Worksheet
    Dim DestSh As Worksheet
    Dim Last As Long
    Dim CopyRng As Range

    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

    Application.DisplayAlerts = False
    On Error Resume Next
    On Error GoTo 0
    Application.DisplayAlerts = True

    Set DestSh = ActiveWorkbook.Worksheets.Add
    DestSh.Name = "RDBMergeSheet"

    'loop through all worksheets and copy the data to the DestSh
    For Each sh In ActiveWorkbook.Worksheets

        'Information worksheet, you can ad more sheets to the array if you want.
        If IsError(Application.Match(sh.Name, _
                                     Array(DestSh.Name, "Information"), 0)) Then

            Last = LastRow(DestSh)

            'Fill in the range that you want to copy
            Set CopyRng = sh.UsedRange

            'Test if there enough rows in the DestSh to copy all the data
            If Last + CopyRng.Rows.Count > DestSh.Rows.Count Then
                MsgBox "There are not enough rows in the Destsh"
                GoTo ExitTheSub
            End If

            'This example copies values/formats, if you only want to copy the
            'values or want to copy everything look at the example below this macro
            With DestSh.Cells(Last + 1, "A")
                .PasteSpecial xlPasteValues
                .PasteSpecial xlPasteFormats
                Application.CutCopyMode = False
            End With

            'Optional: This will copy the sheet name in the H column
            DestSh.Cells(Last + 1, "H").Resize(CopyRng.Rows.Count).Value = sh.Name

        End If


    Application.GoTo DestSh.Cells(1)

    'AutoFit the column width in the DestSh sheet

    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
End Sub

'Common Functions required for all routines:

Function LastRow(sh As Worksheet)
    On Error Resume Next
    LastRow = sh.Cells.Find(what:="*", _
                            After:=sh.Range("A1"), _
                            Lookat:=xlPart, _
                            LookIn:=xlFormulas, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlPrevious, _
    On Error GoTo 0
End Function

Function LastCol(sh As Worksheet)
    On Error Resume Next
    LastCol = sh.Cells.Find(what:="*", _
                            After:=sh.Range("A1"), _
                            Lookat:=xlPart, _
                            LookIn:=xlFormulas, _
                            SearchOrder:=xlByColumns, _
                            SearchDirection:=xlPrevious, _
    On Error GoTo 0
End Function

Open in new window

this code will create a new sheet with all of the data from other tabs in it. also it creates the reference that which data is from which tab.  if you do not want that it can be removed from the code too.

i have answered similar question in here http://www.experts-exchange.com/Software/Microsoft_Applications/Q_28506865.html which worked for the OP

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

ProfessorJimJamMicrosoft Excel ExpertCommented:
you can remove this part line 56 of the code from the above code , if you do not want the sheets reference in the combined worksheet.

            'Optional: This will copy the sheet name in the H column
            DestSh.Cells(Last + 1, "H").Resize(CopyRng.Rows.Count).Value = sh.Name

Open in new window

WO2015Author Commented:
Perfect, thank you!!
ProfessorJimJamMicrosoft Excel ExpertCommented:
You are welcome.

Thanks for the feedback.

Glad it worked
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.