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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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>
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,122
Members
451,399
Latest member
alchavar

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
Back
Top