ANSWER FROM OLD POST ....
Question
I ran into this Formula on VBAExpress
=SUMPRODUCT(--($B$2:$B$8=F2),--($D$2:$D$8="X"))
And I was wondering what the dashes '--' do in a formula? I've never come across using
-- in a formula before
ANSWER........
It's called a double unary minus. Minus minus is the same as plus.
It coerces a TRUE/FALSE boolean into 1/0. The same could be achieved
by multiplying by 1 or adding zero. But -- is in vogue at the moment because
apparently it is a nanosecond or two quicker than the alternatives.
It would more likely be written:
=SUMPRODUCT(($B$2:$B$8=F2)*($D$2:$D$8="X"))
It compares each cell in B2:B8 with F2 and returns an array of TRUE/FALSE values.
Then it compares each cell in D2:D8 with "X" and returns another (equally sized) array
of TRUE/FALSE values. The 2 arrays are multiplied together, and in the process TRUE is
coerced to 1 and FALSE to zero. That results in an array of 1/0 values
(1*1=1, 1*0=0, 0*1=0, 0*0=0). This array is then summed. The effect is a
count of the two conditions being TRUE.
SOURCE: An old post , that I kept , from this board. Sorry I can't remember who wrote the post .