Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
msimms
 
Posts: n/a
Default Boolean comparison: range vs. single cell


This is driving me crazy....I am trying to debug and understand some
cell computations using Excel 2003...but all it does it return an
#VALUE error:
=IF($A$2:$A$26<=H$1,1,0)

But the following WORKS and produces the correct result:
= 100 * SUM(IF(($A$2:$A$26<=G$1) *( $B$2:$B$26 <=
$F2),$C$2:$C$26,0))/$C$27

WHY ? key issue he how to properly compare a vector to a single
cell.

My take on this: $A$2:$A$26<=G$1
Each cell in Column A from 2-26 is being compared to G1.
If ANY ONE OF THEM is less than G1, then the result is "True"....
correct ?

Is there a better, MORE APPROPRIATE way to do this ?


--
msimms
------------------------------------------------------------------------
msimms's Profile: http://www.excelforum.com/member.php...o&userid=30382
View this thread: http://www.excelforum.com/showthread...hreadid=500441

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Alan
 
Posts: n/a
Default Boolean comparison: range vs. single cell

Try
=IF(COUNTIF(A2:A26,"<="&H1)0,1,0)
or
=IF(COUNTIF(A2:A26,"<="&H1),1,0)
Regards,
Alan.
"msimms" wrote in
message ...

This is driving me crazy....I am trying to debug and understand some
cell computations using Excel 2003...but all it does it return an
#VALUE error:
=IF($A$2:$A$26<=H$1,1,0)

But the following WORKS and produces the correct result:
= 100 * SUM(IF(($A$2:$A$26<=G$1) *( $B$2:$B$26 <=
$F2),$C$2:$C$26,0))/$C$27

WHY ? key issue he how to properly compare a vector to a single
cell.

My take on this: $A$2:$A$26<=G$1
Each cell in Column A from 2-26 is being compared to G1.
If ANY ONE OF THEM is less than G1, then the result is "True"....
correct ?

Is there a better, MORE APPROPRIATE way to do this ?


--
msimms
------------------------------------------------------------------------
msimms's Profile:
http://www.excelforum.com/member.php...o&userid=30382
View this thread: http://www.excelforum.com/showthread...hreadid=500441



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove
 
Posts: n/a
Default Boolean comparison: range vs. single cell

msimms wrote...
This is driving me crazy....I am trying to debug and understand some
cell computations using Excel 2003...but all it does it return an
#VALUE error:
=IF($A$2:$A$26<=H$1,1,0)


If you don't enter this as an array formula, it'll return #VALUE!. No
good reason, it's just they way Excel's IF function works. However,
it'd also return #VALUE! if H1 evaluated to #VALUE!. Also, if entered
as an array formula, it'd return an array of 1s and 0s.

But the following WORKS and produces the correct result:
=100*SUM(IF(($A$2:$A$26<=G$1)*($B$2:$B$26<=$F2),$ C$2:$C$26,0))/$C$27


This shouldn't have worked unless you enter it as an array formula,
though it'd return a single value rather than an array.

WHY ? key issue he how to properly compare a vector to a single
cell.

My take on this: $A$2:$A$26<=G$1
Each cell in Column A from 2-26 is being compared to G1.
If ANY ONE OF THEM is less than G1, then the result is "True"....
correct ?


Wrong. It compares *EACH* cell in A2:A26 to G1 and returns an *ARRAY*
of TRUE/FALSE results. If you want to check whether ANY cell in A2:A26
equals G1 and return a SINGLE TRUE/FALSE result, use
COUNTIF($A$2:$A$26,G$1)0.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
msimms
 
Posts: n/a
Default Boolean comparison: range vs. single cell


Wrong. It compares *EACH* cell in A2:A26 to G1 and returns an
*ARRAY*
of TRUE/FALSE results. If you want to check whether ANY cell in A2:A26
equals G1 and return a SINGLE TRUE/FALSE result, use
COUNTIF($A$2:$A$26,G$1)0.


Wow, thanks guys for the fast response....
but how does a TRUE or FALSE result get translated into a NUMERIC VALUE
?
0=false 1=true ????
(I tried entering "=True()" into a cell and formatting it, but it did
not return a number)

If you notice, an array is then multiplied to another array....
I am assuming the number of multiplications is only equivalent to the
length of the vector, correct ?


--
msimms
------------------------------------------------------------------------
msimms's Profile: http://www.excelforum.com/member.php...o&userid=30382
View this thread: http://www.excelforum.com/showthread...hreadid=500441

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove
 
Posts: n/a
Default Boolean comparison: range vs. single cell

msimms wrote...
....
but how does a TRUE or FALSE result get translated into a NUMERIC VALUE?

....

Boolean (TRUE/FALSE) values used as operands to arithmetic operators
are automatically converted into 1s for TRUE and 0s for FALSE.



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
copying cell names Al Excel Discussion (Misc queries) 12 August 11th 05 03:01 PM
Shading a range based on a single cell value. Drew Excel Discussion (Misc queries) 5 July 23rd 05 12:06 AM
cell color index comparison MINAL ZUNKE New Users to Excel 1 June 30th 05 07:11 AM
xls worksheet formatting a single cell Archer------------> Excel Discussion (Misc queries) 1 April 30th 05 07:25 PM
Reveal cell formats and extendable range in tool/statusbar/icon. Danny O'Hern ([email protected]) Excel Worksheet Functions 0 April 29th 05 01:16 PM


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

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"