First thing first, you need to change your >5100 to >=5100 or it will exclude
any account 5100. I'll give you the details here of how it works, as
SUMPRODUCT is a very powerful function that, once learned, will do so much
for you.
Let's give a sample data set (and I will assume the >=5100 correction), and
I'll break down your formula to show why it works.
We'll use a smaller set of data, say row 6-12
G6:G12 = 5007 | 6005 | 5009 | 5822 | 5100 | 5008 | 6000
O6:O12 = 240 | 125 | 415 | 118 | 644 | 557 | 99
Now, just looking at the data, we know the answer should be 240 + 118 + 644
+ 557 = 1559
Let's look at the first SUMPRODUCT
(G6:G59>=5100) this will evaluate into a series of TRUE or FALSE results,
again, as stated, only looking at first 7, so...
(G6:G59>=5100) = FALSE | TRUE | FALSE | TRUE | TRUE | FALSE | TRUE ...
The double dash (double unary negation), essentially turns a text value into
a number if possible. The great thing is, TRUE and FALSE can be turned into
numbers, such as 1 and 0 in this case.
So...
--(G6:G59>=5100) = 0 | 1 | 0 | 1 | 1 | 0 | 1 ...
Then multiplies this by the values in O6:O59
So...
--(G6:G59>=5100) * (O6:O59) = 0 * 240 + 1 * 125 + 0 * 415 + 1 * 118 + 1 *
644 + 0 * 557 + 1 * 99 = 986
And the next 3 terms can be solved just the same way
So...
--(G6:G59>5999) * (O6:O59) = 0 * 240 + 1 * 125 + 0 * 415 + 0 * 118 + 0 * 644
+ 0 * 557 + 1 * 99 = 224
--(G6:G59=5007) * (O6:O59) = 1 * 240 + 0 * 125 + 0 * 415 + 0 * 118 + 0 * 644
+ 0 * 557 + 0 * 99 = 240
--(G6:G59=5008) * (O6:O59) = 0 * 240 + 0 * 125 + 0 * 415 + 0 * 118 + 0 * 644
+ 1 * 557 + 0 * 99 = 557
And finally, we solve based on the four terms
986 - 224 + 240 + 557 = 1559
Hope that clears things up, and don't forget to change the >5100 to >=5100 !!!