For Each Sheet But not all

J

jlclyde

Is there a way to do the For Each sheet and exclude sheets to have it
done to at the same time?

Thanks,
Jay
 
D

Dave Peterson

dim wks as worksheet
for each wks in activeworkbook.worksheets
select case lcase(wks.name)
case is = "not this one", "or this one", "and not this"
'do nothing
case else
'do the real work
msgbox wks.name
end select
next wks

Make sure you type the names of the worksheets in lower case.
 
S

Sheeloo

for each ws in worksheets
if ws.name<>"name you want to exclude" then
'do what you want to do
end if
next
 
J

jlclyde

dim wks as worksheet
for each wks in activeworkbook.worksheets
   select case lcase(wks.name)
       case is = "not this one", "or this one", "and not this"
          'do nothing
       case else
          'do the real work
          msgbox wks.name
   end select
next wks

Make sure you type the names of the worksheets in lower case.

Dave,
You have been saving my butt left and right. Thanks again.
Jay
 
J

Joel

Sub test()

exclude = Array("A", "B", "C")

For Each sht In Sheets
Found = False
For Each itm In exclude
If UCase(sht.Name) = UCase(tim) Then
Found = True
Exit For
End If
If Found = False Then

'enter you code here

End If
Next itm

Next sht


End Sub
 
Top