"--" in formulas

  • Thread starter Thread starter JoelS
  • Start date Start date
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.
 
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.
 
JoelS said:
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.
 
Back
Top