LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.misc
Roger Govier
 
Posts: n/a
Default What does the "--" do?

Hi Nick

The double unary minus "--" coerces the TRUE or FALSE result of the
comparison inside the first set of brackets into 1's or 0's. This could also
be achieved by adding +0 or multiplying with a *1 addition to the formula
but doing a minus, minus (which comes back to the original value) is a
little faster in execution.

The resulting 1's and 0's then multiply the array from the second range and
Sumproduct adds the results to give the final answer.

So if the value in cell D1 were 100, that would be TRUE, and coerced to 1
would be multiplied by the value in F1 would result in the value in F1.
If D2 were not 100, then it would be FALSE hence 0 which multiplying by the
value in F2 would result in 0.


Regards

Roger Govier


thekovinc wrote:
First off, I wasn't sure where to post this because I didn't know if the
-- is classified as a worksheet function or not, but what does it do?
I've seen them in a bunch of posts. I am just curious what they do.

Example:

=SUMPRODUCT(--($D$1:$D$100="100"),$F$1:$F$100)

versus

=SUMPRODUCT(($D$1:$D$100="100"),$F$1:$F$100)

Why does the second one not work?

Thanks,
Nick


 
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



All times are GMT +1. The time now is 01:18 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"