Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not in list of values

Status
Not open for further replies.

dgillz

Instructor
Mar 2, 2001
10,045
US
I am struggling with syntax on this. I need to check a cell's contents for a specific list of values. Here is what I have tried:

If Not (Cells(iRow, 21).Value in ["D","M","N","Q","S","W"]) then.....

which did not work. I also tried this:

if Cells(iRow, 21).Value Not in ["D","M","N","Q","S","W"] then.....

To no avail. I am getting an error that a then or goto is expected where I am using the word "in".

I know this must be simple, but I cannot figure it out. Any help is appreciated.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
I'd suggest the SELECT CASE statement

Code:
SELECT CASE Cells(irow,21)
CASE "D","M","N","Q","S","W"
    'code if true
CASE ELSE
    ' code if false
END SELECT

 
Another way:
If InStr("DMNQSW", Cells(iRow, 21).Value) = 0 Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top