Ignore sheet in loop

cuetipper

Board Regular
Joined
Nov 9, 2018
Messages
67
So how do I ignore the worksheet named "Data".

For Each ws In Sheets
if ws.name="Data" next ws end if
else
'do stuff here
next ws
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Like
Code:
For Each ws In Sheets
   If ws.Name <> "Data" Then
      'do stuff here
   End If
Next ws
 
Upvote 0
Can I modify that to ignore more than one sheet or do I repeat the line?

For Each ws In Sheets
If ws.Name <> "Data" Then
If ws.Name <> "recap" Then
'do stuff here
End If
Next ws
 
Upvote 0
Try
Code:
For Each ws In Sheets
   If ws.Name <> "Data" And ws.Name <> "recap" Then
      'do stuff here
   End If
Next ws
 
Upvote 0
I can not get this to work.
I added tot he top of my code:
For Each WS In Application.Worksheets
If WS.Name <> "Data" Then
WS.Activate


and then at the end:

End If
Next
End Sub


and I get error next without for.
ant idea why?
 
Upvote 0
Without seeing the entire code, I can't tell
 
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

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