"--" in formulas

S

Sheeloo

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.
 
D

David Biddulph

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.
 
J

joeu2004

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top