Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 29
Default Search for value in a range

Is there a function which can search for a value in a range and return a
"true" or "false" if it finds it.

eg. =if(A2=B2:B30,12,0) So if the value in cell A2 is found in the range
B2:B30 then 12, if not then 0.

Obviously this particular formula doesn't work otherwise I wouldn't be
asking. How can I change it so it does what I'm try to make it do.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Search for value in a range

Try it as:
=IF(ISNUMBER(MATCH(A2,B$2:B$30,0)),12,0)
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Student" wrote:
Is there a function which can search for a value in a range and return a
"true" or "false" if it finds it.

eg. =if(A2=B2:B30,12,0) So if the value in cell A2 is found in the range
B2:B30 then 12, if not then 0.

Obviously this particular formula doesn't work otherwise I wouldn't be
asking. How can I change it so it does what I'm try to make it do.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Search for value in a range

On Wed, 30 Jan 2008 15:16:00 -0800, Student
wrote:

Is there a function which can search for a value in a range and return a
"true" or "false" if it finds it.

eg. =if(A2=B2:B30,12,0) So if the value in cell A2 is found in the range
B2:B30 then 12, if not then 0.

Obviously this particular formula doesn't work otherwise I wouldn't be
asking. How can I change it so it does what I'm try to make it do.


=IF(OR(A2=B2:B30),12,0)

entered as an **array-formula** with <ctrl<shift<enter. Excel will places
braces {...} around the formula if you do it correctly.

OR:

=SUMPRODUCT(OR(A2=B2:B30)*12)

entered normally.
--ron
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default Search for value in a range

Try this:

=COUNTIF(B2:B30,A2)*12

Is that something you can work with?
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)

"Student" wrote in message
...
Is there a function which can search for a value in a range and return a
"true" or "false" if it finds it.

eg. =if(A2=B2:B30,12,0) So if the value in cell A2 is found in the range
B2:B30 then 12, if not then 0.

Obviously this particular formula doesn't work otherwise I wouldn't be
asking. How can I change it so it does what I'm try to make it do.





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Search for value in a range

On Wed, 30 Jan 2008 19:27:29 -0500, "Ron Coderre"
wrote:

Try this:

=COUNTIF(B2:B30,A2)*12

Is that something you can work with?
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)


Of course, if there are two matches for A2, this would return 24 and not 12.
--ron
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default Search for value in a range

Hence the
Is that something you can work with?


If there are multiple matches of A2 in B2:B30
then perhaps this:
=IF(COUNTIF(B2:B30,A2),12,0)

That formula is durable against
a blank A2 and blanks within B2:B30.
(assuming that wouldn't be a legitimate match)

Thanks for you comments, Ron.
--------------------------

Best Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)


"Ron Rosenfeld" wrote in message
...
On Wed, 30 Jan 2008 19:27:29 -0500, "Ron Coderre"
wrote:

Try this:

=COUNTIF(B2:B30,A2)*12

Is that something you can work with?
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)


Of course, if there are two matches for A2, this would return 24 and not
12.
--ron




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
search within a range of cells? [email protected] Excel Discussion (Misc queries) 2 April 22nd 07 08:08 AM
Search range for text not in another range simon howard Excel Discussion (Misc queries) 3 March 28th 07 08:44 PM
how do you search a range of cells... Xanadude Excel Discussion (Misc queries) 2 June 6th 05 05:30 AM
How do I search a data range for a particular value then collate . Hulkascooby Excel Discussion (Misc queries) 0 January 19th 05 03:21 PM
How do I get excel search through a range of numbers e.g. 1.99 - . govworker Excel Worksheet Functions 0 December 15th 04 06:11 PM


All times are GMT +1. The time now is 01:01 AM.

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

About Us

"It's about Microsoft Excel"