I am trying to update an ingredient inventory with a few nested For loops and If statements and it worked for the first set which is Malt, but I started getting a Run-time error '9': Subscript out of range. Even when I removed the For loop for the hops it is still giving me the error even though it worked for the malts originally.
The function is supposed to loop through all entries in column AB with row index i to check if the batch has already been accounted for and if the cell is empty then set the variable Brand to the brand name in column B. Each brand has an associated worksheet with the same name as the brand that has the recipe, which lists the amount of each ingredient used.
For i = 3 To Batch_Entry
If Cells(i, 28).Value = "" Then
Dim Recipe As Worksheet
Dim Brand As String
Brand = Range("B" & i)
Set Recipe = Worksheets(Brand)
The error occurs at "Set Recipe = Worksheets(Brand)
When the If statement is true, it is supposed to enter a nested For loop that goes through all the malts used in the recipe and look through all the malts in the Ingredient Inventory worksheet to find the match and update the column with the amount used.
Once it has gone through the malts, it should do the same thing for the hops, yeast, and misc. ingredients used in the recipe, then mark the batch entry at row index i as "yes" and move to the next batch entry (I haven't entered that line of code yet. Waiting until I get the function working). I am pretty new to excel, so I'm sure this isn't the most efficient code to complete the desired task. Any help is appreciated, but hopefully it's an easy fix.
The function is supposed to loop through all entries in column AB with row index i to check if the batch has already been accounted for and if the cell is empty then set the variable Brand to the brand name in column B. Each brand has an associated worksheet with the same name as the brand that has the recipe, which lists the amount of each ingredient used.
For i = 3 To Batch_Entry
If Cells(i, 28).Value = "" Then
Dim Recipe As Worksheet
Dim Brand As String
Brand = Range("B" & i)
Set Recipe = Worksheets(Brand)
The error occurs at "Set Recipe = Worksheets(Brand)
When the If statement is true, it is supposed to enter a nested For loop that goes through all the malts used in the recipe and look through all the malts in the Ingredient Inventory worksheet to find the match and update the column with the amount used.
Once it has gone through the malts, it should do the same thing for the hops, yeast, and misc. ingredients used in the recipe, then mark the batch entry at row index i as "yes" and move to the next batch entry (I haven't entered that line of code yet. Waiting until I get the function working). I am pretty new to excel, so I'm sure this isn't the most efficient code to complete the desired task. Any help is appreciated, but hopefully it's an easy fix.
ORB Inventory and Cost Analysis.xlsm | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | K | L | Z | AA | AB | |||||||||||||||||||||||
2 | Batch # | Brand | Brew Date | Rack Date | Cost per Batch | Cost per oz | Ingredient Inventory Updated | |||||||||||||||||||||||
3 | 94 | Citra Smash | 3/16/22 | 4/23/22 | $563.30 | $ 0.015 | Yes | |||||||||||||||||||||||
4 | 95 | Cucumber Gose | 3/22/22 | 4/25/22 | $919.99 | $ 0.028 | Yes | |||||||||||||||||||||||
5 | 96 | Hibiscus Hoale | 3/25/22 | 4/26/22 | $1,249.17 | $ 0.036 | Yes | |||||||||||||||||||||||
6 | 97 | Becker's Best | 3/29/22 | 5/11/22 | $1,261.65 | $ 0.020 | Yes | |||||||||||||||||||||||
7 | 98 | Aviator | 4/5/22 | 5/2/22 | $529.80 | $ 0.045 | Yes | |||||||||||||||||||||||
8 | 99 | Divine Apparition | 5/2/22 | Yes | ||||||||||||||||||||||||||
9 | 100 | Centurion | 4/7/22 | 4/28/22 | $650.60 | $ 0.018 | Yes | |||||||||||||||||||||||
10 | 101 | Mossy Rock | 4/8/22 | 4/28/22 | $1,271.05 | $ 0.036 | Yes | |||||||||||||||||||||||
11 | 102 | Becker's Best | 4/12/22 | 6/21/22 | $841.65 | $ 0.011 | Yes | |||||||||||||||||||||||
12 | 103 | Cucumber Gose | 5/4/22 | 5/25/22 | $920.07 | $ 0.024 | Yes | |||||||||||||||||||||||
13 | 104 | Aviator | 5/9/22 | 5/23/22 | $519.31 | $ 0.016 | Yes | |||||||||||||||||||||||
14 | 105 | Becker's Best | 5/11/22 | Yes | ||||||||||||||||||||||||||
15 | 106 | Peaches-n-Cream | 5/13/22 | 5/31/22 | Yes | |||||||||||||||||||||||||
16 | 107 | Hop Train | 5/20/22 | 5/31/22 | $685.17 | $ 0.017 | Yes | |||||||||||||||||||||||
17 | 108 | Honey Kolsh | 5/24/22 | 6/8/22 | $652.87 | $ 0.017 | Yes | |||||||||||||||||||||||
18 | 109 | Becker's Best | 5/27/22 | Yes | ||||||||||||||||||||||||||
19 | 110 | Kiwi Cucumber Gose | 5/31/22 | 6/24/22 | $743.59 | $ 0.019 | Yes | |||||||||||||||||||||||
20 | 111 | Injector | 6/7/22 | 7/13/22 | $1,425.29 | $ 0.052 | Yes | |||||||||||||||||||||||
21 | 112 | Golden Promises | 6/9/22 | 7/7/22 | $898.63 | Yes | ||||||||||||||||||||||||
22 | 113 | Lavendar Wheat | 6/17/22 | $541.55 | $ 0.014 | Yes | ||||||||||||||||||||||||
23 | 114 | Centurion | 6/24/22 | 7/7/22 | $662.58 | $ 0.017 | Yes | |||||||||||||||||||||||
24 | 115 | Cucumber Gose | 6/29/22 | 7/12/22 | $1,079.27 | $ 0.030 | Yes | |||||||||||||||||||||||
25 | 116 | Becker's Best | 7/6/22 | $1,280.79 | Yes | |||||||||||||||||||||||||
26 | 117 | Aviator | 7/8/22 | $527.55 | Yes | |||||||||||||||||||||||||
27 | 118 | Citra Smash | 7/15/22 | $779.48 | ||||||||||||||||||||||||||
28 | 119 | Derailment | 7/19/22 | $580.93 | ||||||||||||||||||||||||||
Batch Data |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
B3:B28 | List | ='ORB Brands'!$A$2:$A$100 |
K3:K1048576 | List | ='Drop Downs'!$C$2:$C$6 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
H3 | H3 | =15-2 |
H5 | H5 | =10-1 |
C3:C13 | C3 | ='Ingredients & Pricing'!C2 |
C14:C35 | C14 | ='Ingredients & Pricing'!C14 |
G3:G35 | G3 | =D3*E3+F3 |
J3:J35 | J3 | =G3+(H3*D3)-I3 |
ORB Inventory and Cost Analysis.xlsm | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | |||
1 | Citra Smash | ||||||||||||||||||||
2 | |||||||||||||||||||||
3 | Malt | Hops | Yeast | Misc. | |||||||||||||||||
4 | Product | Recipe Unit | Amount | Cost | Product | Recipe Unit | Amount | Cost | Product | Recipe Unit | Amount | Cost | Product | Recipe Unit | Amount | Cost | |||||
5 | Rahr Standard 2-Row | Price / lb | 275 | 190.85 | Hallertau Magnum - Green Products Hops | Price / lb | 2.5 | $24.98 | Fermentis SafAle™ US-05 - 500 g | Price / g | 500 | 63.5 | Lactic Acid 88% - 4 kg | Price / mL | 450 | 3.06 | |||||
6 | Simpsons Finest Golden Promise™ | Price / lb | 197 | 189.514 | Citra 2019 | Price / lb | 1 | $17.50 | BSG Brewers’ Gypsum (Calcium Sulfate) - 50 lb | Price / g | 63 | 0.0882 | |||||||||
7 | Dingemans Cara 20 | Price / lb | 32 | 31.104 | Citra 2019 | Price / lb | 2 | $35.00 | BSG Brewers’ Calcium Chloride - 50 lb | Price / g | 15 | 0.051 | |||||||||
8 | Weyermann® Acidulated Malt | Price / lb | 15 | 17.31 | Citra 2019 | Price / lb | 2 | 35 | BSG Brewers’ Gypsum (Calcium Sulfate) - 50 lb | Price / g | 19 | 0.0266 | |||||||||
9 | Weyermann® CARAFOAM® | Price / lb | 15 | 14.73 | Citra 2019 | Price / lb | 2 | 35 | BSG Brewers’ Calcium Chloride - 50 lb | Price / g | 81 | 0.2754 | |||||||||
10 | Citra 2019 | Price / lb | 3 | 52.5 | Whirlfloc® G - 5 lb | Price / g | 25 | 0.75 | |||||||||||||
11 | Citra 2019 | Price / lb | 3 | 52.5 | Yeastex® 82 - 5 lb | Price / g | 40 | 0.804 | |||||||||||||
12 | Fermcap® AT - 4 kg | Price / mL | 40 | 6.888 | |||||||||||||||||
13 | Biofine® Clear - 25 kg | Price / mL | 500 | 8.05 | |||||||||||||||||
Citra Smash |
Cell Formulas | ||
---|---|---|
Range | Formula | |
S5 | S5 | =250+200 |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
G5:G13 | List | ='Ingredients & Pricing'!$K$2:$K$100 |
B1 | List | ='ORB Brands'!$A$2:$A$100 |
L5:L13 | List | ='Ingredients & Pricing'!$S$2:$S$99 |
Q5:Q13 | List | ='Ingredients & Pricing'!$AA$2:$AA$99 |
B5:B13 | List | ='Ingredients & Pricing'!$C$2:$C$100 |
Attachments
-
10DF40C9-36AA-4645-B16D-35032167D612_4_5005_c.jpeg23.5 KB · Views: 7
-
BBDE968D-AD65-4289-A1C0-EA9A6A870E02.jpeg75.8 KB · Views: 8
-
560231E1-2A3E-4C7E-814A-72776915123F.jpeg116 KB · Views: 6
-
98CF90D0-284A-4DDD-B1C8-33976D0659E7.jpeg77.9 KB · Views: 7
-
1DF065A5-681D-4FF7-A4A1-389083B37A7F.jpeg201.8 KB · Views: 6
-
96E9786C-1D04-444C-8E72-7E7901A7B8F8.jpeg185.4 KB · Views: 7
-
1CDF733B-3CA6-4B9D-B105-68C38C5DDB21.jpeg155.2 KB · Views: 7