# SUMIF

#### dcartwright

##### New Member
Good afternoon

I would appreciate some help with a problem that I have.

Below is a simplified version of a spreadsheet I have.
What I am trying to do is this. I want a formula writing that looks up a "Reference Number" in sheet 2 of my spreadsheet. I then want it to add up from Sheet 1 any any values from column D (Consumption Kwh) where column A (Reference Number) is the value from Sheet 1 that I have specified AND where Shhet 1 column B (Year) = 2005-06 AND where Sheet 1 column C (Period)is between 3 and 8

Dave
Book1
ABCD
1ReferenceNumberYearPeriodConsumptionKwh
2187366932005-0633,893.00
3187366932005-0621,722.00
4497343452004-054166,442.00
5187366932005-06727,458.00
6927366972005-06623,715.00
7111136602005-061049,717.00
8187366932005-06514,116.00
9187366932004-0578,723.00
Sheet1

### Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Not very pretty, but this seems to be working for me (this is assuming the formula will be added to Sheet1--change the references if/where needed):

=SUMPRODUCT(--(\$A\$2:\$A\$9=Sheet2!\$A\$1)*(\$B\$2:\$B\$9="2005-06")*(\$C\$2:\$C\$9>=3)*(\$C\$2:\$C\$9<=8),\$D\$2:\$D\$9)

I can't quite get that formula to work.

In your first section you wrote "=SUMPRODUCT(--(\$A\$2:\$A\$9=Sheet2!\$A\$1)

Should that not be sheet1?

My actual sheet that I am writing the formula in is called "Gas Summary" this has a column D which holds the "Reference number" my sheet that the formula looks in is called "AutoLoaded Gas" this sheet holds my reference numbers, years, period's and consumption.

Your formula does not seem to be quite right unless I am entering it wrong.

Somewhat cleaned up...

=SUMPRODUCT(--(ReferenceRange=Reference),--(YearRange=Year),--(PeriodRange>=StartVal),--(PeriodRange<=EndVal),ConsumptionRange)

Like I said:
(this is assuming the formula will be added to Sheet1--change the references if/where needed):

In short, the formula is being placed on Sheet1, where the data lies and as such does not need to have the Sheet referenced. The value you want to look for is in Sheet2, cell A1, which is why it is written the way it is. Remember, this is all based off of the sample you gave in the first post as that is all there is (was) to work from.

I tried your formula again this morning and it has worked a treat.

Regards

Dave

Replies
3
Views
142
Replies
3
Views
111
Replies
11
Views
506
Replies
1
Views
313
Replies
2
Views
191

1,219,935
Messages
6,151,055
Members
451,006
Latest member
dhinze84

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back