Combining data in multiple sheets into one sheet

ferijen

New Member
Joined
Nov 16, 2004
Messages
12
I have a multi-sheeted workbook (about 80 sheets I think) where every sheet contains data in the same layout & format: 8 columns wide, although each sheet varies in the number of rows.

I'd like to combine all this data so it is on one sheet - essential a copy/paste action for each sheet in the workbook - but I wondered if anyone else had already written the vb code which would make my task easier? I know that I won't exceed the maximum number of rows when it is all put on to one sheet.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
54,401
Office Version
  1. 365
Platform
  1. Windows
ferijen

You could give this a go as a starting point.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> CombineSheets()
    <SPAN style="color:#00007F">Dim</SPAN> wsC <SPAN style="color:#00007F">As</SPAN> Worksheet
    <SPAN style="color:#00007F">Dim</SPAN> ws <SPAN style="color:#00007F">As</SPAN> Worksheet
    <SPAN style="color:#00007F">Dim</SPAN> lr <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> nr <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>

    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN>
    Sheets.Add(After:=Sheets(Sheets.Count)).Name = "Combined"
    <SPAN style="color:#00007F">Set</SPAN> wsC = Sheets("Combined")
    nr = 1
    
    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> ws <SPAN style="color:#00007F">In</SPAN> ActiveWorkbook.Worksheets
        <SPAN style="color:#00007F">If</SPAN> ws.Name <> wsC.Name <SPAN style="color:#00007F">Then</SPAN>
            lr = ws.Range("A" & Rows.Count).End(xlUp).Row
            ws.Range("A1:H" & lr).Copy _
                Destination:=wsC.Cells(nr, 1)
                nr = nr + lr
        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
    <SPAN style="color:#00007F">Next</SPAN> ws
    
    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,422
Messages
5,837,142
Members
430,477
Latest member
roseinsydney

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top