Improve company productivity with a Business Account.Sign Up



Posted on 2013-05-09
Medium Priority
Last Modified: 2013-05-09

I have a code that verifies the index of a sheet. In this case, the index is 4 and the sheet name is SN 300-3

i have the following line:

ElseIf sht.Index > 3 And InStr(1, sht.Name, "-") And InStr(1, sht.Name, "SN") then

and returns false. I don't know why is happening? I test the statement individually and works well but when i mix the three doesn't work! Only works two by two!
Question by:joyacv2
LVL 29

Assisted Solution

IrogSinta earned 600 total points
ID: 39154011
How about
ElseIf sht.Index > 3 And sht.Name Like "SN*-*" then

Author Comment

ID: 39154016

It's works perfect, but did you know why my line of code doesn't work?
LVL 81

Accepted Solution

byundt earned 1400 total points
ID: 39154117
The ElseIf statement is expecting a True or False result--but you are calculating the result of a Boolean (sht.Index > 3) with two integers (the InStr). If you force the two InStr to return a Boolean value, then your statement will work:
ElseIf (sht.Index > 3 And InStr(1, sht.Name, "-") > 0 And InStr(1, sht.Name, "SN") > 0) Then

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Excel allows various different methods to link Excel files to each other. This includes relative paths, mapped drives (or the local drive) and UNC paths. UNC paths are the least robust of the three.
Debits & Credits have been the foundation of financial record keeping since 1494 - over 500 years. Excel is a brilliant tool for leveraging this ancient power - not least with Pivot Tables, sorting and filtering.  This article seeks by illustration …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

587 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question