Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Question 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.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 587
Default 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.




  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,514
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,514
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,514
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF statement checking if a cell's text is red Shazzer Excel Worksheet Functions 7 April 3rd 23 02:40 PM
Checking whether a value in a list is present in a second list [email protected] Excel Discussion (Misc queries) 5 June 1st 07 02:30 PM
checking for a value in a list kcrad Excel Discussion (Misc queries) 3 March 13th 07 04:20 PM
If Statement Checking Formula NOT Value in a Cell Marathon Excel Discussion (Misc queries) 7 January 28th 07 10:31 PM
Checking if value is in a list roeaster Excel Worksheet Functions 1 April 15th 05 05:00 PM


All times are GMT +1. The time now is 09:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"