Combine all sheets into one except for one

jmazorra

Well-known Member
Joined
Mar 19, 2011
Messages
715
Hello:

I have the below statement that combines all worksheets into one. Essentially, it combines all into one called "Combined Reports". However, I would like to rewrite the sub so that a sheet called "emailList" is not combined into the report.

Any help will be appreciated.

Code:
Sub combine_all_Reports()



    Dim J As Integer
    Dim s As Worksheet


    On Error Resume Next


    ' copy headings
    Sheets(2).Activate
    Range("B8").EntireColumn.Select
    Selection.Copy Destination:=wksCombinedReports.Range("B9")


    For Each s In ActiveWorkbook.Sheets
        If s.Name <> "Combined Reports" Then
            Application.GoTo Sheets(s.Name).[B1]
            Selection.CurrentRegion.Select
             Selection.Copy Destination:=Sheets("Combined Reports"). _
              Cells(Rows.Count, 1).End(xlUp)(2)
              wksCombinedReports.Cells.EntireColumn.AutoFit


        End If
    Next
    
    End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
jmazzora,

You might consider the following tweak...

Code:
Sub combine_all_Reports()
    Dim J As Integer
    Dim s As Worksheet

    On Error Resume Next

    ' copy headings
    Sheets(2).Activate
    Range("B8").EntireColumn.Select
    Selection.Copy Destination:=wksCombinedReports.Range("B9")

    For Each s In ActiveWorkbook.Sheets
        [COLOR=#ff0000]If s.Name <> "Combined Reports" And s.Name <> "emailList" Then[/COLOR]
            Application.GoTo Sheets(s.Name).[B1]
            Selection.CurrentRegion.Select
            Selection.Copy Destination:=Sheets("Combined Reports"). _
              Cells(Rows.Count, 1).End(xlUp)(2)
            wksCombinedReports.Cells.EntireColumn.AutoFit
        End If
    Next
End Sub


Cheers,

tonyyy
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,203
Members
452,617
Latest member
Narendra Babu D

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