Solved

Excel Formula to Selectively Sum Data

Posted on 2012-03-20
5
326 Views
Last Modified: 2012-03-20
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
Comment
Question by:dbbishop
  • 2
  • 2
5 Comments
 
LVL 50

Assisted Solution

by:barry houdini
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

by:
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

by:dbbishop
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

by:leptonka
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

by:barry houdini
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel Score Formula 5 49
Help with Excel formula 6 38
Error in formula not increasing value 2 15
excel help 4 19
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now