Sum a range based upon a criteria in ANOTHER column

T

Tom Jones

I have a table that is setup like:

A B
--------------------
1 $100 Y
2 $50 Y
3 $300 N

I need to sum everything in column A ONLY IF the "matching" value in column
B is "Y".

In the above example the result would be $150, ($100 + $50).

In C I could perform the above like this:

int sum = 0;
for (int i = 1; i <= 3; i++)
{
if (Worksheet[B, i] == "Y")
{
sum += Worksheet[A, i];
}
}

Any suggestions would be appreciated!

Thanks,
TJ
 
Top