Excluding Worksheets from a Workbook Copy

WxShady13

Board Regular
Joined
Jul 24, 2018
Messages
185
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I have a workbook that has 3 static worksheets that are named the same in every workbook. The additional worksheets are dynamically created based on the employee name and training record selected by the supervisor. I need to copy a range of data on every worksheet but the 3 static ones (***NOTE I do not know the last row for each worksheet), onto one master worksheet so that I can then create a chart. I have the code where it will copy all the worksheets, but how do I remove the 3 static ones?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi & welcome to MrExcel.
Maybe something like
Code:
Dim Ws As Worksheet
For Each Ws In Worksheets
   If Ws.name <> "Me" And Ws.name <> "Myself" And Ws.name <> "I" Then
      'do something
   End If
Next Ws
 
Upvote 0
Thank you for the quick response...I added the And statements but now it doesn't copy anything...

My static worksheets are Instructions, Summary, User Record and Training Matrix. Those are the first 4 in each workbook, would it be easier to eliminate the first 4?
 
Upvote 0
OK, how about
Code:
Dim i As Long
For i = 5 To Worksheets.Count
   With Sheets(i)
      'do something
   End With
Next i
 
Upvote 0
I apologize I am very new to VBA code....on the 'do something I know the .copy command should be the first line followed by where to paste it. I had previously used ws.Range("A1:G70").Copy however the ws.Range no longer works...What is the command to copy the worksheets, but only get the cells with data?
 
Upvote 0
Which sheet are you copying to?
 
Upvote 0
Ok, try this
Code:
Sub ttt()
   Dim i As Long
   For i = 5 To Worksheets.Count
      With Sheets(i)
         .Range("A1:G70").Copy Sheets("Summary").Range("A" & Rows.Count).End(xlUp).Offset(1)
      End With
   Next i
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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