SUMIF on noncontiguous ranges

Excel Chimp

Board Regular
Joined
Oct 30, 2008
Messages
90
Please see sample data. My goal is for N5 and down to sum any cost value with the corresponding code (1,2,3...).

I read a bit and tried to create named ranges for the Range and Sum Range; CODE and COST respectively. They are the same size and shape, and thought they should work. However, I'm getting a value error returned in cells N5 and down.

Thanks for any help.
Excel Workbook
ABCDFGHIJMNOP
4CostPer unit 216CodeCostAllocated costPer unit 216CodeCostPer UnitCode
5Appliances7,04632.622Backflow8005962.76Personnel#VALUE!1
6Auto Loan10,11746.84Boiler repair4883631.682Repairs & Maintenance#VALUE!2
7Vertical Blinds1,7868.273Drainage75560.26Make Ready & Redecorating3
8Cabinetry2,26710.503Extinguishers1,6371,2195.64Recreational Amenities4
9Contract Services5
Sheet1
Excel 2010
Cell Formulas
RangeFormula
C4="Per unit "&$C$1
C5=$B5/$C$1
C6=$B6/$C$1
C7=$B7/$C$1
C8=$B8/$C$1
I4="Per unit "&$C$1
I5=H5/$C$1
I6=H6/$C$1
I7=H7/$C$1
I8=H8/$C$1
H5=G5*($C$1/$I$1)
H6=G6*($C$1/$I$1)
H7=G7*($C$1/$I$1)
H8=G8*($C$1/$I$1)
N5=SUMIF(CODE,$P5,COST)
N6=SUMIF(CODE,$P6,COST)
Excel Workbook
NameRefers To
CODE=Sheet1!$D$5:$D$46,Sheet1!$J$5:$J$42
COST=Sheet1!$B$5:$B$46,Sheet1!$H$5:$H$42
Workbook Defined Names
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
SUMIF expects contiguous ranges. Why don't you just add 2 together?

=SUMIF($D$5:$D$46,P5,$B$5:$B$46)+SUMIF($J$5:$J$42,P5,$G$5:$G$42)
 
Upvote 0
Doh! (slaps forehead)
Thanks so much- I work alone and sometimes you need another person to step back and see the obvious. Keep It Simple Stupid, right?
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,011
Members
452,374
Latest member
keccles

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top