If statement checking list

B

B Rucks

Is there a way to use an If statement to see if a cell value is equal t
any value in the list and return a "yes" if true or "no" if false? Th
list is in the same worksheet
 
I

isabelle

hi,

=IF(COUNTIF(B:B,A1)>0,TRUE,FALSE)



Sub Macro1()
v = Range("A1") ' adapt cell value
If Application.CountIf(Range("B:B"), v) > 0 Then ' adapt column
MsgBox True
Else
MsgBox False
End If
End Sub



--
isabelle



Le 2012-01-19 12:35, B Rucks a écrit :
 
G

GS

B Rucks presented the following explanation :
Is there a way to use an If statement to see if a cell value is equal to
any value in the list and return a "yes" if true or "no" if false? The
list is in the same worksheet.

Take a look at the LOOKUP functions in online help. You can use one of
those to check the list range combined with...

IF(NOT(ISERROR(?LOOKUP(...))))
 
G

GS

GS formulated the question :
B Rucks presented the following explanation :

Take a look at the LOOKUP functions in online help. You can use one of those
to check the list range combined with...

IF(NOT(ISERROR(?LOOKUP(...))))

Isabelle's solution is a better choice since it uses less functions.
You could modify it as follows to get the results specified...

=COUNTIF(ListRange,Criteria)>0,"Yes","No")

...where ListRange is the address where the list is located, and
Criteria is the value you want to find OR a ref to a cell that contains
the value.
 

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

Top