Complicated Index formula with OR not working

oblix

Board Regular
Joined
Mar 29, 2017
Messages
183
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
  8. 2007
  9. 2003 or older
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Hi there all

I have a complicated index formula I can not resolve.

Background:

I created a sheet with a shopping list (sheet name - SL1)
in this sheet
column B has the product description (eg apples)
column Q the name of the company I entend to buy from (eg company A)
column R the oty i intend buying (eg 10)
column S the price of product for this company (eg $10-00)

in onother sheet i created a purchase order form with these formulas (sheet name PO1)
column B product decription
=IFERROR(INDEX('SL1'!$B$7:$B$605,SMALL(IF(('SL1'!$R$7:$R$605>0)*('SL1'!$Q$7:$Q$605=$K$5),ROW('SL1'!$B$7:$B$605)),ROW(1:1))-6,1),"")

column E Qty: =IFERROR(ROUNDUP(INDEX('SL1'!$R$7:$R$489,MATCH(A20,'SL1'!$B$7:$B$489,0)),0),"")

column F price: =IF(ISERROR(MATCH(A20,'SL1'!$B$7:$B$489,0)),"",INDEX('SL1'!$S$7:$S$489,MATCH(A20,'SL1'!$B$7:$B$489,0)))

k5 = name of company I want to order from

This formulas worked beautifully and was able to drag formulas down the columns ad there is my order form.
If I change the name of the company (k5), the order updates for that company.

Problem:
The boss asked me to add columns in the shopping list to add another possible company per product line.
I did this by adding:
column U: Company name 2
column V: QTY 2
column W: Price 2

Now the purchase order needs to look at two set of columns (q,r,s) and (U,V,W) to populate as company of that order can be in one of those column groups.


For the life of me I dont know how to ammend those three formulas to make this work and believe I have tried.
Please please is there any body that can assist!

Thank you in advance
 
Last edited by a moderator:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
This would be a lot easier to resolve if you used the XL2BB addin (see link in my signature below) to post an example of your data (fictionalise any confidential info) along with the expected results.

It would also help if you update your profile to show which version of excel you are using, to do this, click on your user name at the top right of the page then 'Account details'. Scroll down and check the box for the correct version of excel, then scroll to the bottom and save changes.
 
Upvote 0
03_Monthly_Shopping_Master.xlsm
K
11
PO_1
 
Upvote 0
Cell Formulas
RangeFormula
T9,X9:Y9T9=SUM(T10:T25)
A10:B25A10='SHOPPING LIST'!A10
Q10:Q25,W10:W25,U10:U25,S10:S25Q10=+'SHOPPING LIST'!AV10
R10:R25R10=+K10*'C:\Users\Marsau\Desktop\Master V1\Master V1 - TEST\Master Rations\[02_Price_Comparison_Master.xlsm]COM DECISION'!I10
T10:T25,X10:X25T10=IFERROR(R10*S10,"")
V10:V25V10=+K10*'C:\Users\Marsau\Desktop\Master V1\Master V1 - TEST\Master Rations\[02_Price_Comparison_Master.xlsm]COM DECISION'!L10
Y10:Y25Y10=IFERROR(X10+T10," ")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
X24:X25Expression=AND($A22<>"""",#REF!=ROW())textNO
U24:W25,Y24:Y25Expression=AND($A22<>"""",#REF!=ROW())textNO
F24:R25,T24:T25Expression=AND($A22<>"""",#REF!=ROW())textNO
Z9Expression=AND($A8<>"""",#REF!=ROW())textNO
Q607,A9:Z605Expression=AND($A9<>"""",$AA$9=ROW())textNO
 
Upvote 0
Cell Formulas
RangeFormula
C20:C25C20=IF(ISERROR(MATCH(A20,'SL1'!$B$7:$B$489,0)),"",INDEX('SL1'!$O$7:$O$489,MATCH(A20,'SL1'!$B$7:$B$489,0)))
D20:D25D20=IF(ISERROR(MATCH(A20,'SL1'!$B$7:$B$489,0)),"",INDEX('SL1'!$P$7:$P$489,MATCH(A20,'SL1'!$B$7:$B$489,0)))
E20E20=IFERROR(ROUNDUP(INDEX('SL1'!$R$7:$R$489,MATCH(A20,'SL1'!$B$7:$B$489,0)),0),"")
F20:F25F20=IF(ISERROR(MATCH(A20,'SL1'!$B$7:$B$489,0)),"",INDEX('SL1'!$S$7:$S$489,MATCH(A20,'SL1'!$B$7:$B$489,0)))
G20:G25G20=IF(ISERROR(MATCH(A20,'SL1'!$B$7:$B$489,0)),"",INDEX('SL1'!$Z$7:$Z$489,MATCH(A20,'SL1'!$B$7:$B$489,0)))
H20:H25H20=IF(E20="","",E20*F20)
E21:E25E21=IFERROR(ROUNDUP(INDEX('SL1'!$K$7:$K$489,MATCH(A21,'SL1'!$B$7:$B$489,0)),0),"")
A20:A25A20=IFERROR(INDEX('SL1'!$B$7:$B$605,SMALL(IF(('SL1'!$R$7:$R$605>0)*('SL1'!$Q$7:$Q$605=$K$5),ROW('SL1'!$B$7:$B$605)),ROW(1:1))-6,1),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
Named Ranges
NameRefers ToCells
Print_Area=PO_1!$A$4:$H$274A23
 
Upvote 0
Try this, none of the formulas need to be array confirmed.
Cell Formulas
RangeFormula
C20:C25C20=IFERROR(INDEX('SL1'!$O$7:$O$489,MATCH(A20,'SL1'!$B$7:$B$489,0)),"")
D20:D25D20=IFERROR(INDEX('SL1'!$P$7:$P$489,MATCH(A20,'SL1'!$B$7:$B$489,0)),"")
E20:E25E20=IFERROR(AGGREGATE(15,6,'SL1'!$R$7:$V$605/('SL1'!$R$7:$V$605>0)/('SL1'!$Q$7:$U$605=$K$5),ROWS(A$20:A20)),"")
F20:F25F20=IFERROR(ROUNDUP(AGGREGATE(15,6,'SL1'!$S$7:$W$605/('SL1'!$R$7:$V$605>0)/('SL1'!$Q$7:$U$605=$K$5),ROWS(A$20:A20)),2),"")
G20:G25G20=IFERROR(INDEX('SL1'!$Z$7:$Z$489,MATCH(A20,'SL1'!$B$7:$B$489,0)),"")
H20:H25H20=IF(E20="","",E20*F20)
A20:A25A20=IFERROR(INDEX('SL1'!$B:$B,AGGREGATE(15,6,ROW('SL1'!$B$7:$B$605)/('SL1'!$R$7:$V$605>0)/('SL1'!$Q$7:$U$605=$K$5),ROWS(A$20:A20))),"")
 
Upvote 0
Thank you for assitance.
A20 formula in PO1 working great. But Qty (E20) and Price not giving the correct answer.
Please assist
 
Upvote 0
Could you post an example with the incorrect results? As far as I can see the formulas are working correctly, if they are not then it means that there could be something in your data that I have not allowed for in the formula.
 
Upvote 0
Cell Formulas
RangeFormula
C20:C40C20=IFERROR(INDEX('SL1'!$O$7:$O$489,MATCH(A20,'SL1'!$B$7:$B$489,0)),"")
D20:D40D20=IFERROR(INDEX('SL1'!$P$7:$P$489,MATCH(A20,'SL1'!$B$7:$B$489,0)),"")
E20E20=IFERROR(AGGREGATE(15,6,('SL1'!$R$7:$V$605)/('SL1'!$R$7:$V$605>0)/('SL1'!$Q$7:$U$605=$K$5),ROWS(A$20:A20)),"")
F20:F40F20=IFERROR(ROUNDUP(AGGREGATE(15,6,'SL1'!$S$7:$W$605/('SL1'!$R$7:$V$605>0)/('SL1'!$Q$7:$U$605=$K$5),ROWS(A$20:A20)),2),"")
G20:G40G20=IFERROR(INDEX('SL1'!$Z$7:$Z$489,MATCH(A20,'SL1'!$B$7:$B$489,0)),"")
E21:E40E21=IFERROR(AGGREGATE(15,6,'SL1'!$R$7:$V$605/('SL1'!$R$7:$V$605>0)/('SL1'!$Q$7:$U$605=$K$5),ROWS(A$20:A21)),"")
A20:A40A20=IFERROR(INDEX('SL1'!$B:$B,AGGREGATE(15,6,ROW('SL1'!$B$7:$B$605)/('SL1'!$R$7:$V$605>0)/('SL1'!$Q$7:$U$605=$K$5),ROWS(A$20:A20))),"")
H20:H40H20=IF(E20="","",E20*F20)
H41H41=SUM(H20:H40)
H42H42=SUMIF(G20:G40,"=x",H20:H40)
H44H44=H43*H42
H47H47=H41+H44+H46+H45
 
Upvote 0
03_Monthly_Shopping_Master.xlsm
ABCDEFGHIJKLOPQRSTUVWXYZ
6Ser No.RATION ITEMISSUE SCALEKg/ Lt/ eaTotal Issue PatternITEMS REQUIREDUOMSTOCK ON HANDAMOUNT TO BE DEMANDEDUOMQTYXITEM PACKAGING5UOMSUPPLIER 1QTY 1PRICE PER DOQCOMP 1 SUB TOTALSUPPLIER 2QTY 2PRICE PER DOQCOMP 2 SUB TOTALTOTALTaxable
7
8xxxxxxxxxxxxxxxxxxxxxx
9ASTARCH WEIGHT PER MEAL60xR 3,783.706R 2,481.45R 666.251
10A001Corn Meal (Mielie Meal)0.125kg12.0 meals150kg150kg60X2.5kg 0  G/ Catering60R 19.85R 1,191.00 x
11A002Instant Potato Powder0.150kg0.0 meals0kg-kg-X2kg 0   0   x
12A003Lasagne Sheets0.125kg2.0 meals25kg25kg50X500gG/ Catering50R 18.56R 928.00 0   x
13A004Macaroni0.050kg2.5 meals13kg13kg25X500gMALESELA25R 10.68R 267.00 0   x
14A005Noodle Shells0.050kg1.0 meals5kg5kg10X500gC/ House10R 15.09R 150.90 0   x
15A006Noodles Ribbon0.050kg1.0 meals5kg5kg10X500gBidfood10R 14.26R 142.60 0   x
16A007Potato Chips Frozen 10mm0.150kg5.0 meals75kg75kg30X2.5kgBidfood30R 20.14R 604.20 0   x
17A008Potato Chips Frozen Oven Bake0.150kg1.0 meals15kg15kg6X2.5kg 6   0   x
18A009Potato Fresh Pre-Prepared0.175kg12.5 meals219kg219kg88X2.5kg 0  VANANI88R 10.50R 918.75 x
19A010Potatoes Fresh0.200kg2.0 meals40kg40kg4X10kgVANANI4R 85.00R 340.00 0   x
20A011Rice Parboiled Brown0.050kg0.5 meals3kg3kg1X2.5kg 0  GOOD MANNERS1R 24.20R 24.20 x
21A012Rice Parboiled White0.050kg12.0 meals60kg60kg30X2kgGOOD MANNERS30R 24.20R 726.00 0   x
22A013SAMP0.125kg3.5 meals44kg44kg18X2.5kgMistro18R 17.50R 306.25 0   x
23A014Spaghetti0.050kg5.0 meals25kg25kg50X500gC/ House25R 12.75R 318.75Bidfood25R 13.90R 347.50R 666.25x
24A015Vetkoek Plain Medium2.000ea0.0 meals0kg-kg-X2.5kg 0   0   x
25A016Wraps Plain Medium2.000ea0.0 meals0kg-kg-X2.5kg 0   0   x
26xxxxxxxxxxxxxxxxxxxxxx
27BFAT WEIGHT PER DAY30.0 mealsxR 2,250.00R -R -
SL1
Cell Formulas
RangeFormula
E9,X9:Y9,T9E9=SUM(E10:E25)
A10:D25A10='SHOPPING LIST'!A10
E10:E25E10=SUMIFS('SHOPPING LIST'!E10:AI10,'SHOPPING LIST'!$E$6:$AI$6,">="&'SL1'!$L$4,'SHOPPING LIST'!$E$6:$AI$6,"<="&'SL1'!$S$4)
F10:F25F10=+C10*$F$4*E10
W10:W25,U10:U25,S10:S25,O10:Q25,J10:J25,G10:G25G10=+'SHOPPING LIST'!AL10
I10:I25I10=MAX(0,F10-(H10*M10))
K10:K25K10=IF(I10=0,0,+I10/M10)
R10:R25R10=+K10*'C:\Users\Marsau\Dropbox\My PC (DESKTOP-SVL8AIM)\Desktop\Master V2\Master V1 - TEST\Master Rations\[02_Price_Comparison_Master.xlsm]COM DECISION'!I10
T10:T25,X10:X25T10=IFERROR(R10*S10,"")
V10:V25V10=+K10*'C:\Users\Marsau\Dropbox\My PC (DESKTOP-SVL8AIM)\Desktop\Master V2\Master V1 - TEST\Master Rations\[02_Price_Comparison_Master.xlsm]COM DECISION'!L10
Y10:Y25Y10=IFERROR(X10+T10," ")
E27,X27:Y27,T27E27=SUM(E28:E31)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
X24:X25Expression=AND($A22<>"""",#REF!=ROW())textNO
U24:W25,Y24:Y25Expression=AND($A22<>"""",#REF!=ROW())textNO
E24:E25,Z24:Z25Expression=AND($A22<>"""",#REF!=ROW())textNO
F24:R25,T24:T25Expression=AND($A22<>"""",#REF!=ROW())textNO
Z27Expression=AND($A26<>"""",#REF!=ROW())textNO
Z9Expression=AND($A8<>"""",#REF!=ROW())textNO
Q607,A9:Z605Expression=AND($A9<>"""",$AA$9=ROW())textNO
 
Upvote 0

Forum statistics

Threads
1,215,404
Messages
6,124,715
Members
449,184
Latest member
COrmerod

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