If Sheet Name, No Action

  • Thread starter Thread starter ryguy7272
  • Start date Start date
R

ryguy7272

Is there an easier way to do this:
If (sh.Name) <> "SH1 - Ryan" Then
If (sh.Name) <> "SH1 - Jimmy" Then
If (sh.Name) <> "SH1 - Tim" Then
If (sh.Name) <> "SH1 - Todd" Then
If (sh.Name) <> "SH1 - Frank" Then
If (sh.Name) <> "SH1 - Susie" Then


Something like this:
If (sh.Name) <> "SH1 - *" Then

(but this does not work…)

Regards,
Ryan---
 
You could use a select case statement something like this...

select case sh.name
case "SH1 - Ryan", "SH1 - Jimmy", "SH1 - Tim", "SH1 - Todd", _
"SH1 - Frank", "SH1 - Susie"
case else
'Now do yoru stuff
end select
 
Ryan

Try the Like operator; maybe something like:

Sub test3()

For Each sh In Sheets

If sh.Name Like "Sh*" Then MsgBox sh.Name

Next sh

End Sub


Good luck.

Ken
Norfolk, Va
 

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