NumberCruncher311
New Member
- Joined
- Feb 5, 2013
- Messages
- 26
I need help with combining Index and Match. Can someone tell me why this isn't working? Below is an example of my worksheet. What I'm trying to do is create a dynamic Index/Worksheet combo that will help me identify the additional cost for the type of filling and size of cake. So, for example - I'd like the Index/Match formula to tell me that it's an additional $1.00 for a 6" round cake with Ganache frosting.
So that this can be dynamic, I've done the following (I should add that this is for VBA coding) ...
I have the following named ranges:
A1:F5 "FrostingAddOn"
A1:A5 "FrostingNames"
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD]_4Round[/TD]
[TD]_6Round[/TD]
[TD]_7Round[/TD]
[TD]_8Round[/TD]
[TD]_9Round[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Brown Sugar[/TD]
[TD].5[/TD]
[TD].75[/TD]
[TD]1.00[/TD]
[TD]1.25[/TD]
[TD]1.50[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Chocolate Hazelnut[/TD]
[TD].5[/TD]
[TD].75[/TD]
[TD]1.00[/TD]
[TD]1.25[/TD]
[TD]1.50[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Chocolate Peanut Butter[/TD]
[TD].6[/TD]
[TD].8[/TD]
[TD]1.25[/TD]
[TD]1.5[/TD]
[TD]1.75[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Ganache[/TD]
[TD].75[/TD]
[TD]1.00[/TD]
[TD]1.25[/TD]
[TD]1.50[/TD]
[TD]1.75[/TD]
[/TR]
</tbody>[/TABLE]
Here is the code I've been using and it doesn't work:
Note - the data is getting pulled from several combo boxes, I don't know how to simplify this any more than I have.
So that this can be dynamic, I've done the following (I should add that this is for VBA coding) ...
I have the following named ranges:
A1:F5 "FrostingAddOn"
A1:A5 "FrostingNames"
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD]_4Round[/TD]
[TD]_6Round[/TD]
[TD]_7Round[/TD]
[TD]_8Round[/TD]
[TD]_9Round[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Brown Sugar[/TD]
[TD].5[/TD]
[TD].75[/TD]
[TD]1.00[/TD]
[TD]1.25[/TD]
[TD]1.50[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Chocolate Hazelnut[/TD]
[TD].5[/TD]
[TD].75[/TD]
[TD]1.00[/TD]
[TD]1.25[/TD]
[TD]1.50[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Chocolate Peanut Butter[/TD]
[TD].6[/TD]
[TD].8[/TD]
[TD]1.25[/TD]
[TD]1.5[/TD]
[TD]1.75[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Ganache[/TD]
[TD].75[/TD]
[TD]1.00[/TD]
[TD]1.25[/TD]
[TD]1.50[/TD]
[TD]1.75[/TD]
[/TR]
</tbody>[/TABLE]
Here is the code I've been using and it doesn't work:
Note - the data is getting pulled from several combo boxes, I don't know how to simplify this any more than I have.
Code:
Dim Tier1 As String, AddOnCost As String
Dim Tier1AC As Long
If OneTier.Tier1Frost.Value = "Chocolate Hazelnut" Then
AddOnCost = "Chocolate Hazelnut"
ElseIf OneTier.Tier1Fost.Value="Chocolate Ganache" Then
AddOnCost = "Ganache"
End If
Tier1 = OneTier.Tier1Size.Value
Tier1AC = Application.WorksheetFunction.Index("FrostingAddOn", Application.WorksheetFunction.Match("AddOnCost", "FrostingNames", 0), Application.WorksheetFunction.Match(Tier1, "FrostingAddOn", 0))
MsgBox "Additional Cost Is: " & Tier1AC