ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   "--" in formulas (https://www.excelbanter.com/excel-discussion-misc-queries/224559-formulas.html)

JoelS

"--" in formulas
 
What does "--" do when used in a formula?

Sheeloo[_4_]

"--" in formulas
 
It
converts numbers stored as text back to numbers so that the formulas which
expect numbers as arguments can work...
converts TRUE and FALSE to 1 and 0...

It is basically two - together...
Applied on a TEXT/Boolean forces Excel to convert it to a number... so a
single - will also do the above but give you -5 for 5. By putting two - you
convert it back to 5 since -(-5) is 5.

"JoelS" wrote:

What does "--" do when used in a formula?


Dave Peterson

"--" in formulas
 
J.E. McGimpsey has some notes at:
http://mcgimpsey.com/excel/formulae/doubleneg.html

JoelS wrote:

What does "--" do when used in a formula?


--

Dave Peterson

David Biddulph[_2_]

"--" in formulas
 
It is generally used to convert either text or a boolean to an equivalent
number.
Put '42 into cell A1. =-A1 gives -42, =--A1 gives 42
Similarly FALSE is converted to zero, and TRUE to 1.
--
David Biddulph

"JoelS" wrote in message
...
What does "--" do when used in a formula?




[email protected]

"--" in formulas
 
"JoelS" wrote:
What does "--" do when used in a formula?


It is simply double negation. For example, if A1 contains 1, -A1 results in
-1, --A1 results in 1 because -(-1) is 1, and ---A1 is -1 again.

However, you will often see "--" used to convert boolean values (TRUE,
FALSE) to numeric values (1, 0). You can accomplish the same thing by
multiplying by 1 or adding zero. This is particularly useful in SUMPRODUCT
expressions.



All times are GMT +1. The time now is 10:36 PM.

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