Can I use "In" in an "If" statement?

M

mbrockhaus

I want to determine if a value in column A is in a list of values, using an
if statement. Do I need to list each condition separately? For example, is
there a better way to write the following statement?

=IF(OR($A2<>"Benchmark",$A2<>"Benchmark Folder",$A2<>"Physical
Name",$A2="Label Part"), "y", "n")
 
B

Bearacade

You can save 4 characters by doing this...

=IF(OR($A2="benchmark",$A2="benchmark folder",$A2="physica
name",$A2="label part"), "n", "y")

it doesn't check for case, so you don't have to cap the firs
letter...

The other thing you can do is make a table of what you are checking,
put it in L1:L4

=IF(ISERROR(MATCH(A2,L1:L4)), "y", "n"
 
D

Dave Peterson

I would think you'd want an exact match:
=IF(ISERROR(MATCH(A2,L1:L4,0)), "y", "n")

or alternatively:
=IF(ISnumber(MATCH(A2,L1:L4,0)), "n", "y")
 
Top