VBA to Copy Range from Muliple Worksheets in one master

Elle Mc

New Member
Joined
Jan 29, 2019
Messages
4


Hi All,

I am hoping someone can help. I have a spread sheet with 30+ tabs and I want to copy certain named tabs for the same range on each selected tab into 1 master sheet. The below works if I have only 1 to exclude but I have multiple to exclude . how do I amend to either include 20+ sheets or exclude 20+sheets?


Sub Master()


Dim Sht As Worksheet


For Each Sht In ActiveWorkbook.Worksheets


If Sht.Name <> "Master" Then


Sht.Select


Range("A4:W89").Copy


Sheets("Master").Select


Range("A65536").End(xlUp).Offset(1, 0).Select


Selection.PasteSpecial Paste:=xlPasteValues


Else


End If


Next Sht


End Sub




 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
How about
Code:
Sub ElleMc()
   Dim Sht As Worksheet
   
   For Each Sht In ActiveWorkbook.Worksheets
      Select Case Sht.Name
         Case [COLOR=#ff0000]"Master", "Sheet1", "Sheet2"[/COLOR]
         Case Else
            Sht.Range("A4:W89").Copy
            Sheets("Master").Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
     End Select
   Next Sht
End Sub
Change the part in red to the sheets you don't want to copy
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,737
Messages
6,180,659
Members
452,992
Latest member
TokugawaIesuma

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