Sorry. I didn't forgot, I just didn't had time yesterday. So here is explanation.
-- is called double unary operator and it's used in excel to convert TRUE/FALSE into 1/0.
It's similliar to 1* or 0+ but it has some difference.
If you have TRUE/FALSE in the cell, to convert it to number you can use:
=1*TRUE (result 1)
=0+TRUE (result 1)
=-TRUE (result -1 so you need --TRUE to get result 1)
I've put attacment so I will refer to it.
With data like:
In formula it look like this:
You can see a step where TRUE/FALSE is converted into 1/0. Without -- you would get result 0.
Only difference is where you have non-numeric value in 2nd column then multiplying * return error (because you can not mutliply number with a text).
And -- ignore number (it act more like a SUM function when you select numbers and text with SUM function).
So from this data:
A fucntion with * will return:
And that's what happend in your code.
By double unary operator (--) you get:
Bearing in mind the above analysis USUALLY it's better to use double unary operator than mutliplying.
I emphasize usually, because there are cases when you must use first approach.
In other cases, you might want to return error if in 2nd column is text. You will use first approach again.
None of them is better - it's just metter of what you want in case when in 2nd column is entered non-numeric value.
More likely you would like to have result as a number, that's why I said usually is better to use second approach.
Bookmarks