View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Look for Sheet name, and then skip...

Technically no. This is using it like a boolean where anything not zero is
true.
If InStr(1, WS, "APN", vbTextCompare) Or _
InStr(1, WS, "Sum", vbTextCompare) Then

Since Instr returns the location of the sub string within the string, and
zero if not found, then 0 would indicate it was found. the result of the
comparison with 0 is a boolean result.

--
Regards,
Tom Ogilvy



"SteveDB1" wrote:

Hi Rick,
Yes, it's a looped routine, to work through all worksheets in a single
workbook, and then through multiple workbooks. But here I'm mainly interested
in how to work through all worksheets in a single workbook, for the purpose
of skipping a worksheet with a specific name.
Thank you for the response.
I'll go read up on the InStr() routine further.
I definitely think that the latter form--

If InStr(1, WS, "APN", vbTextCompare) 0 Or _
InStr(1, WS, "Sum", vbTextCompare) 0 Then

will work more for my purposes.
If I understand this correctly, the zero is acting as a boolean here,
correct?
Where 1 is true, and 0 would also be true?


"Rick Rothstein (MVP - VB)" wrote:

I'm not sure if you are running this in a loop or just processing one single
sheet, but sheets.name is not a valid reference. Assuming for this example
that WS is your worksheet name, this is the If-Then statement that you are
looking for...

If InStr(WS, "APN") 0 Or InStr(WS, "Sum") 0 Then

Note that as written, this test is case-sensitive (I assumed you wanted that
from the capitalizations used in your example). If you want the test to be
case-insensitive, use this instead....

If InStr(1, WS, "APN", vbTextCompare) 0 Or _
InStr(1, WS, "Sum", vbTextCompare) 0 Then

Rick


"SteveDB1" wrote in message
...
Morning all.
I have numerous workbooks with a series of named sheets, two or 3 of these
sheets has a specific name that I want to skip.
I.e.,
If sheets.name = "*APN*" or "*Sum*= true (where the asterisk denotes some
unknown value/variable)
then
skip/bypass/nextsheet/etc...
else
Run "mymacro"
how would I accomplish this?

Thank you.