ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   If statement checking list (https://www.excelbanter.com/excel-worksheet-functions/333384-if-statement-checking-list.html)

B Rucks

If statement checking list
 
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.

isabelle

If statement checking list
 
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 :
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.





GS[_2_]

If statement checking list
 
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(...))))

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc



GS[_2_]

If statement checking list
 
GS formulated the question :
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(...))))


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.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc



GS[_2_]

If statement checking list
 
Correction...

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

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc




All times are GMT +1. The time now is 08:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com