For Each Next

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

Hi,

I have 12 sheets and need to run For Each - Next loop only
on 9 of them.
How would I exclude 3 other sheets?

I can't amend sheet names ( or sheet code names).


TIA,

Greg
 
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Name <> "whatever" And ws.Name <> "whateverelse" _
And ws.Name <> "whateveragain" Then
'run your procedure
End If
Next
 
for each ws in worksheets
if ws.name<>"name1" and ws.name<>"name2" etc
 
You could also use casing. Would be easier to modify if new sheets ar
excluded.


Sub SheetMod()
Dim ws As Worksheet
For Each ws In Worksheets
Select Case ws.Name
Case "--1st sheet to exclude--"
'Null
Case "--2nd sheet to exclude--"
'Null
Case "--3rd sheet to exclude--"
'Null
Case Else
*** code to modify other sheets ***
End Select
Next

End Su
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top