Solved

# Excel Formula to Selectively Sum Data

Posted on 2012-03-20
340 Views
I have a sheet that has text in column A, a amounts in column B and dates in column C. In row 1, columns O through Z I have the names of Months (January..December).
In the January column, row 2 (cell O2), I want to create a formula that will SUM all values in column B where MONTH(C#) = 1. Likewise in cell P2, I want to sum all rows in column B where MONTH(C#) = 2. And so on.

The result is 12 formulas, one for each month, that displays the total amount in colukmn B for that month (or 0 if nothing exists yet for the month).
0
Question by:dbbishop
• 2
• 2

LVL 50

Assisted Solution

barry houdini earned 250 total points
ID: 37743422
Try this formula in O2 copied across

=SUMPRODUCT((TEXT(\$C\$2:\$C\$100,"mmmm")=O\$1)+0,\$B\$2:\$B\$100)

assumes data in rows 2 to 100, adjust as required

regards, barry
0

LVL 7

Accepted Solution

leptonka earned 250 total points
ID: 37743530
You can use this formula in O2 and copy across columns:

=SUMPRODUCT(--(MONTH(\$C\$2:\$C\$6)=COLUMN()-COLUMN(\$O1)+1),\$B\$2:\$B\$6)

(rows from 2 to 6 - you can change)

(nb: "mmmm" in TEXT formula is language-dependent, it will not work in some non-english environment.)

Cheers,
Kris
0

LVL 15

Author Closing Comment

ID: 37743741
Both, in my case work and produce the same results. I've accepted Kris' as the best solution as he does take language into consideration, even though I am not considering running this code in a computer with Chinese set as the language any time in the near future, it may help others. I've split the points evenly. Thanks to both of you.
0

LVL 7

Expert Comment

ID: 37743834
Thank you!
The problem is not just Chinese but for example my Hungarian, where "hhhh" stands for "mmmm"
Cheers,
Kris (she :-)
0

LVL 50

Expert Comment

ID: 37744211
It's a fair point :)

You could possibly use COLUMNS function to avoid having 2 COLUMN functions, i.e.

=SUMPRODUCT(--(MONTH(\$C\$2:\$C\$6)=COLUMNS(\$O2:O2)),\$B\$2:\$B\$6)

regards, barry
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…