# Sum Values in One Range Based on Criteria in Another

I have a simple spreadsheet, two columns "Amount" (col Q) and "Account" (col O). I want to get the sum of the "Amount" column where the corresponding "Account" forum equals "Paypal".

This is as far as I can get!

``````=SUM(Q:Q)*(O:O="Paypal")
``````
• Your above formula would would if you wrote it this way: `=SUM(Q:Q*(O:O="Paypal"))`, and committed it using Ctrl+Shift+Enter. – Ellesa Oct 10 '11 at 21:18
• That works but it will be super-slow compared with `SUMIF`. Array formulae seem to work on the whole column (down to row 1048576), so if you need to use them, it's best to use a more limited range (e.g. `Q2:Q2000`). – benshepherd Sep 17 '13 at 9:26

I believe rather than using `SUM()` you want the `SUMIF()` function. I don't have Excel to hand but I believe you need your formula to be

``````=SUMIF(O:O,"Paypal",Q:Q)
``````

From this site

The syntax for the SumIf function is:

``````SumIf( range, criteria, sumRange )
``````

range is the range of cells that you want to apply the criteria against. (your column containing "Paypal"

criteria is used to determine which cells to add. - In your case matching "paypal"

sumRange are the cells to sum.

Also see this Microsoft help page, and this page which has some more advanced functions such as DSUM and SUMPRODUCT.