For Each Sheet But not all

  • Thread starter Thread starter jlclyde
  • Start date Start date
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
 
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.
 
for each ws in worksheets
if ws.name<>"name you want to exclude" then
'do what you want to do
end if
next
 
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
 
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
 

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