How to merge multiple spreadsheets in Excel 2003

Hi Experts. I have collected storage performance data for 30 MS Exchange servers. The higher ups want to see it in a spreadsheet. How do I merge these documents into a single spreadsheet? Thank you!
Who is Participating?
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.

Hi, Rhiaanon44.

Please see the code below. A few notes...
(1) Set the XHEADER_ROWS constant to the no. of rows in the header (so it isn't duplicated from the second and subsequent sheets). You can set this to 0 if you want all rows from all sheets.
(2) The macro unprotects, unfilters, unhides rows and columns the two sheets.
(3) Because formulas may cause problems in the new "Merge" sheet, the macro pastes values only. Obviously it can be changed if you want formatting also or formulas instead.
(4) The macro doesn't bother checking if "Merge" already exists - instead it fails ungracefully.
(5) The results are slightly untidy if the second (or subsequent) sheet only has the header rows (i.e. no data).
Option Explicit


Sub Merge_Multiple_Sheets_Paste_Values()

Dim xNewSheet As Worksheet
Dim xOldSheet As Worksheet
Dim xSheet As Worksheet
Dim xResponse As Long
Dim xhold As String
Dim xLast_Row As Long
Dim xStart_Row As Long
Dim xFirst As Boolean

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

    Set xNewSheet = Sheets.Add
    xNewSheet.Name = "Merge"
    xFirst = True
    For Each xOldSheet In ActiveWorkbook.Sheets '(Array("Sheet1", "Sheet2"))
        If Not xOldSheet.Name = "Merge" Then
            If xOldSheet.ProtectContents Then xOldSheet.Unprotect ' If there's a password then add it as a string here.
            If xOldSheet.FilterMode Then xOldSheet.ShowAllData
            xOldSheet.Cells.EntireColumn.Hidden = False
            xOldSheet.Cells.EntireRow.Hidden = False
            xLast_Row = Sheets("Merge").Range("A1").SpecialCells(xlLastCell).ROW
            If xFirst Then
                xStart_Row = 1
                xFirst = False
                '''If xLast_Row = XHEADER_ROWS Then Exit For
                xStart_Row = XHEADER_ROWS + 1
                xLast_Row = xLast_Row + 1
            End If
            xOldSheet.Range("A" & xStart_Row & ":" & xOldSheet.Range("A1").SpecialCells(xlLastCell).Address).Copy
            Sheets("Merge").Cells(xLast_Row, 1).PasteSpecial (xlPasteValues)
        End If
With Application
    .EnableEvents = True
    .ScreenUpdating = True
    .Calculation = xlAutomatic
End With

End Sub

Open in new window


Ehm, I should probably have said that I am assuming the data is already in 30 sheets in the workbook. If any of this is incorrect, please let me know the details!

Rhiaanon44Author Commented:
Hi Redmonb.All 30 are in a spreadsheet. However, I should have said I am novice with excel. This work was given to me because I am the new guy.  =)  
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).


We were all there once, but at least you've found your way here!

What we're going to do isn't going to be too complicated - as long as I explain properly, so please bear with me. :)

OK, some questions,...
(1) Which version of Excel are you using?
(2) If the file isn't too big, can you post it here? (If the data is confidential (or you're just not sure) then the correct answer is "No".) If not, can you tell me
(a) what kind of file it is,
(b) on average, roughly how many rows per sheet,
(c)  Are the headers for each sheet identical?
(3) Have you ever looked at a macro within Excel?

Rhiaanon44Author Commented:
There are 37 server names but I just put several bogus ones there. Also, there are 6 columns more of these kind of data. All 30 sheets have the same data requested for the 37 servers.                                                            

Excellent, thanks.

In the attached file, I added a new sheet called Fred and copied into it the data from the original sheet (changing most of the numbers). I then copied the macro into the file, changed the XHEADER_ROWS constant to 0 and ran the macro.

The result is in the "Merge" sheet. Have a look and see whether it's acceptable for you.

BTW, I'll be finishing here for the night in the next 15 minutes or so. I'll be back again in about 6 or 7 hours. How much longer will you be here for and when will you be back again?


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
John?! Sorry, Rhiaanon44, I mixed up two posts. Definitely time for bed!
Rhiaanon44Author Commented:
Thanks Redmonb. I will be back on in the AM. I am looking at your work. Awesome! Thanks!
Rob HensonFinance AnalystCommented:
Without wishing to further complicate Brian's work, can I suggest a Pivot Table from multiple sources as another option. If the layouts of the 37 separate sheets are the same, the pivot table will consolidate all sheets into one sheet and will enable grouping etc.

There are lots of Pivot Table tutorials dotted around the net that should give enough detail of how to do this.

Rob H
Rhiaanon44Author Commented:
Thank you both! I cannot thank you enough!!!
Thanks, Rhiaanon44. Good suggestion Rob.
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.