Newbie struggling with Sumproduct problem

sdel_nevo

New Member
Joined
Jan 16, 2015
Messages
28
Hi Guys

I have been battling with this issue for a while now after inheriting this spread sheet from a previous employee who has since left the company before I started

I will try to explain my problem in plain English as best as I can, here goes.

I have a spread sheet with two workbooks, "IRs" and "price Codes"

on the IRs workbook I need to calculate the price of scrap produced based on the part number being scrapped by month.

the Work book "Price codes" holds the average price of parts by month in this format

C D E F G H I
Months Month Number CU AG Ni Tin Alloy
3 01/01/15 1 1.00 2.00 3.00 4.00 1.00
4 01/02/15 2 1.00 2.00 3.00 4.00 5.00
5 01/03/15 3 0.00 0.00 0.00 0.00 0.00
6 01/04/15 4 0.00 0.00 0.00 0.00 0.00
7 01/05/15 5 0.00 0.00 0.00 0.00 0.00
8 01/06/15 6 0.00 0.00 0.00 0.00 0.00
9 01/07/15 7 0.00 0.00 0.00 0.00 0.00
10 01/08/15 8 0.00 0.00 0.00 0.00 0.00
11 01/09/15 9 0.00 0.00 0.00 0.00 0.00
12 01/10/15 10 0.00 0.00 0.00 0.00 0.00
13 01/11/15 11 0.00 0.00 0.00 0.00 0.00
14 01/12/15 12 0.00 0.00 0.00 0.00 0.00


The work book "Irs" hold various details about the item being scrapped but my problem is this

I Have the Month Number In Column B of the "IRs" Work Book
I have a part number in column G of the "IRs" work book
I have the cost value in Column Q of the "IRs" Work Book

In column Q I have this code
=(IF(OR(LEFT($G8,2)="BB",LEFT($G8,2)="EB",LEFT($G8,2)="CA",LEFT($G8,2)="EC"),SUMPRODUCT(--('Price Codes'!$D$3:$D$14=$B8)*SUM('Price Codes'!$E$4:$E$4)*$J8),"0.00")-$H$8)

This code looks up the month in the Work book "Price codes" ('Price Codes'!$D$3:$D$14=$B8) based on the month of the entry on the "IRs" work book from cell $B8, then gets the correct price from the "price Codes" work book *SUM('Price Codes'!$E$4:$E$4)*$J8, $J8 holds the quantity, if the part does not start with either BB, EB, CA or EC then 0.00 is returned

This code is getting the correct price if I set the cell reference to the correct cell from the "Price codes" work book $E$4:$E$4 but my question is this

what do I need to change to get the correct price from the "Price Codes" work book automatically based on the month

I have been trying to get my head around this problem for a while now, I am used to working with Access VBA but I am totally new to excel and I am struggling with the syntax.

Any help or pointers would be really really appreciated

I am really sorry if this has been asked before

Steve
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Welcome to the forum!

It's a little confusing, but is this anywhere close?


Excel 2010
BGJQ
7Month NumberPart NumberQtyCost Value
81NI50150
IRs
Cell Formulas
RangeFormula
Q8=IFERROR((SUMIF('Price Codes'!D3:D14,IRs!B8,INDEX('Price Codes'!E3:I14,0,MATCH(IRs!G8,'Price Codes'!E2:I2,0)))*J8)-H8,0)




Excel 2010
CDEFGHI
2MonthsMonth NumberCUAGNiTinAlloy
301/01/2015112341
401/02/2015212345
501/03/2015300000
601/04/2015400000
701/05/2015500000
801/06/2015600000
901/07/2015700000
1001/08/2015800000
1101/09/2015900000
1201/10/20151000000
1301/11/20151100000
1401/12/20151200000
Price Codes
 
Upvote 0
Try

=(IF(OR(LEFT($G8,2)={"BB","EB","CA","EC"}),SUMIF('Price Codes'!$D$3:$D$14,$B8,'Price Codes'!$E$4:$E$4)*$J8,"0.00")-$H$8)
 
Last edited:
Upvote 0
Hi formR and Gaz_Chops

many thanks for the replys, my god that was quick

I will try the codes sent and will let you know how I get on

Many many thanks

Steve
 
Upvote 0
Hi Steve, I forgot to alter the range E4:E4, so
=(IF(OR(LEFT($G8,2)={"BB","EB","CA","EC"}),SUMIF('Price Codes'!$D$3:$D$14,$B8,'Price Codes'!$E$3:$E$14)*$J8,"0.00")-$H$8)
 
Upvote 0
Hi Gaz_Chops

wow that works brill

Many many thanks, forums like this is what makes the internet so great

Thank you so much for your help

Steve
 
Upvote 0
Realised you don't need the OR, so
=(IF(LEFT($G8,2)={"BB","EB","CA","EC"},SUMIF('Price Codes'!$D$3:$D$14,$B8,'Price Codes'!$E$4:$E$4)*$J8,"0.00")-$H$8)
 
Upvote 0
So you always want to return a value from column E on the "Price Codes" sheet then?
 
Upvote 0
@FormR, I think you missed the bit that checks for LEFT($G8,2)={"BB","EB","CA","EC"}
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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