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.
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
47,926
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>
 

Watch MrExcel Video

Forum statistics

Threads
1,122,476
Messages
5,596,380
Members
414,063
Latest member
N_Bates

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