Avatar of aeolianje
Flag for United States of America asked on

Combine Excek worksheets

I maintain weekly time reporting worksheets (within a single Excel file) and want to combine them into one worksheet in order to summary information over the year.  

The column headings from each sheet are consistent.  

I would like to capture the sheet name as a new column in order to differentiate the data once combined.

Attached is a sample.

Thanks for your help,
Microsoft Excel

Avatar of undefined
Last Comment

8/22/2022 - Mon
Ken Butters

You didn't specify what information from each sheet you expected to see in the New Summary sheet... but the following routine will create a new summary sheet, and loop through all other existing sheets, and add the tab/sheet name in the top row... 1 per column.
Sub Summarize()

    Dim nextColumn As Long
    Dim ws As Worksheet
    Dim newWorksheet As Worksheet
    Set newWorksheet = Sheets.Add
    newWorksheet.Name = "Year End Summary"
    nextColumn = 0
    For Each ws In ActiveWorkbook.Worksheets
        If ws.Name <> "Year End Summary" Then
            nextColumn = nextColumn + 1
            newWorksheet.Cells(1, nextColumn) = ws.Name
        End If
End Sub

Open in new window


I would like the contents of each sheet included in the summary sheet -- with an extra column indicated which sheet it came from.  Attached is a sample spreadsheet showing the "Year End Summary" spreadsheet resulting from the code -- and a 'Desired Results' spreadsheet showing what I'm really looking for.  Hope that clarifies.

Ken Butters

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

This is perfect!!!!  Thanks so much for your help.

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy