Create an order list based on configuration 'recipes' in Excel 2010
Question
I have been creating a large-ish list of mechanical devices and the parts required to assemble them. Basically what I have are three worksheets.
One with all orderable parts (e.g. screws, nuts, bolts) and their order quantities,
one worksheet with the amounts and types of parts required to build specific devices (E.g. a widget needs 3 screws, 0 nuts and 4 bolts)
and one summary sheet where one is supposed to enter which devices one wants to build.
Since each of parts aren't orderable in single quantities, but rather in larger packages (e.g. 500 screws, 100 bolts, etc.), I need some solution to read the 'to be built'-sheet, lookup all gadgets, add the respective parts needed and create a list of how many boxes of each parts I need.
I have tried somehow doing it via vlookup, but the queries just boggled my mind and I am inexperienced with VBA. Is there an easy solution I am overlooking? Thank you very much.
Edit
Sample Data below:
This is the Recipe list of the devices
Device Name Part 1 Amount 1 Part 2 Amount 2 Part 3 Amount 3 Price Gadget Screws 20 Nuts 40 Bolts 12 6,14 € Widget Screws 10 Bolts 12 Washers 100 2,02 € Thingie Nuts 11 Washers 122 Bolts 14 2,93 €
This is the parts list and order size
Part Order-size Price Price per Unit Screws 500 20 € 0,040 € Nuts 100 12 € 0,120 € Bolts 200 9 € 0,045 € Washers 1000 10 € 0,010 €
This is the Order list for the devices
Item Amount Gadget 14 Widget 22 Thingie 121
And now I would like to have a table created (or a report, or a text file or just any kind of summarized output) that looks like this:
these numbers are now made up
Parts to be ordered Amount of packages Price Screws 1 20€ Nuts 3 36€ Bolts 2 18€ Washers 5 50€
I don't have any useful code to share, since I played around with vlookups inside of vlookups and all I got was a headache...
Solution
First, make an intermediate step by adding columns to the order list (this pastes nicely to Excel with a space deliminter, sorry about the formatting here). You may wish to consider formatting the Recipe
tab differently, but I have used what you have):
Item Amount Screws Bolts Nuts Washers
Gadget 14 280 168 560 0
Widget 22 220 264 0 2200
Thingie 121 0 1694 1331 14762
Second, use the following formula for the formula under "screws" and drag down/over:
=$B2*(SUMIFS(recipe!$C:$C,recipe!$B:$B,order!C$1,recipe!$A:$A,order!$A2)+SUMIFS(recipe!$E:$E,recipe!$D:$D,order!C$1,recipe!$A:$A,order!$A2)+SUMIFS(recipe!$G:$G,recipe!$F:$F,order!C$1,recipe!$A:$A,order!$A2))
This calculates a SUMIFS
based on the Item as well as the PartType from your recipe list. Because you have three columns of parts you need to check on your Recipe
tab you need to have essentially the same formula repeated 3x. This is multiplied by the total numbers of those parts to give you the total number of each basic part for each item. It would be 1/3 as much formula text if each Item/basicPart had its own row entry.
Now that you have the total quantity of each basic part for each Item
calculated, you need to write the Report
formula to give you the amount of packages. I've added an intermediate total # required
column to make this more clear.
Parts to be ordered total # required Amount of packages Price
Screws 500 1 20 €
Nuts 1891 19 228 €
Bolts 2126 11 99 €
Washers 16962 17 170 €
To sum the total number of each part, you can either just manually set the formula as =sum(order!C:C)
as appropriate based on which column each is, or use the following formula:
=SUM(OFFSET(order!B:B,0,MATCH(A2,order!$C$1:$F$1,FALSE)))
This finds the matching column on the order tab built above and sums it. To reduce complexity you could hardcode this. However, add this to cell Reports!B2 and drag down.
Finally, use the following formulas to get the Amount of Packages
(entered in Reports!C2):
=ROUNDUP(B2/VLOOKUP(A2,ordersize!A:B,2,FALSE),0)
and then get your total cost (entered in Reports!D2):
=C2*VLOOKUP(A2,ordersize!A:C,3,FALSE)
You may have to change some of the formulas based on the sheet names I used.
I think it is worth noting that you probably could restructure this data in such a way that a pivot table gives you all the output you need with minimal Excel formulas. So, the "easy solution" is learn how pivot tables work and determine how best to restructure your information (and what elements can be changed) and allow yourself to avoid some of the more complicated Excel formula work.