Solved

# Can't get SUMIF to do what I want

Posted on 2013-10-29
223 Views
I have a spreadsheet that has dates in the cells A3:AA3
In cell A5:AA5 are meter readings

I want to sum all the meter readings where the month the date is 10 (October) but I can't seem to get sumif to do the job its got to be something like this:

=SUMIF(A3:AA3,"Month()=10",A5:AA5)
0
Question by:KCTS
• 4
• 4

LVL 23

Expert Comment

Try:

=SUMPRODUCT(--(MONTH(A3:AA3)=10),A5:AA5)
0

LVL 24

Expert Comment

you can use SUM and IF...

=SUM(IF(MONTH(A3:AA3)=10,A5:AA5))
Enter using [ctrl]+[shift]+[enter]
0

LVL 70

Author Comment

Thanks @NB_VC that works a treat - I hope you don't mind a couple of supplementary questions.

1. Can you explain what -- does - I've not seen that use before
2. How can I also calculate the average in the same scenario
0

LVL 23

Accepted Solution

NBVC earned 500 total points
the -- coerces the results of True/False from the conditional decks to 1/0 so the math can be done.
to get average
=SUMPRODUCT(--(MONTH(A3:AA3)=10),A5:AA5)/ SUMPRODUCT(--(MONTH(A3:AA3)=10))
0

LVL 70

Author Closing Comment

Thanks for your help - much appreciated :-)
0

LVL 70

Author Comment

opps - one slight problem - the average includes blank cells - how can I exclude blank cells?
0

LVL 23

Expert Comment

Try:

=SUMPRODUCT(--(A5:AA5<>""),--(MONTH(A3:AA3)=10),A5:AA5)/ SUMPRODUCT(--(A5:AA5<>""),--(MONTH(A3:AA3)=10))
0

LVL 70

Author Comment

Once again many thanks
0

LVL 23

Expert Comment

You are welcome.
0

## Featured Post

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
My experience with Windows 10 over a one year period and suggestions for smooth operation
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…