Consolidating Worksheets Into One

mchel_27

Board Regular
Joined
Sep 9, 2009
Messages
75
Hello,

I have a workbook with over 300 worksheets in it. I want to combine all of them into one worksheet so that it becomes workable data for me. All of the worksheets have columns that have the same type of data in them and they are formatted the same. Is there an easy way to do this?

Thanks!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Another possibility:

Code:
Public Sub ConsolidateWorkbook()
'Variable Declaration: dWS = Destination Worksheet, sLR = Source Worksheet Last Row
'                      dLR = Destination Last Row
Dim ws          As Worksheet, _
    dWS         As Worksheet, _
    sLR         As Long, _
    dLR         As Long, _
    RowHeader   As VbMsgBoxResult
    
Application.ScreenUpdating = False
Sheets.Add Before:=Sheets(1)
ActiveSheet.Name = "Master"
Set dWS = ActiveSheet
RowHeader = MsgBox("Do your worksheets contain a header?", vbYesNo)
For Each ws In ActiveWorkbook.Worksheets
    If ws.Name <> dWS.Name Then
        dLR = dWS.Range("A" & rows.Count).End(xlUp).Row + 1
        sLR = ws.Range("A" & rows.Count).End(xlUp).Row
        Select Case RowHeader
            Case vbYes
                ws.Range("A2:A" & sLR).EntireRow.Copy Destination:=dWS.Range("A" & dLR)
            Case vbNo
                ws.Range("A1:A" & sLR).EntireRow.Copy Destination:=dWS.Range("A" & dLR)
        End Select
    Else
        If RowHeader = vbYes Then Sheets(Sheets.Count).rows(1).Copy Destination:=dWS.Range("A1")
    End If
Next ws
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,839
Members
452,948
Latest member
UsmanAli786

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