Equation using drop down as variable

zxcless

New Member
Joined
Feb 26, 2018
Messages
4
Hello! I'm trying to get an equation to work for a peppercorn blend form I have, where changing cell B2 from Gram to TSP (teaspoon) will change the output in the Total cells. See below for the form.

TSP Field Selected - https://i.imgur.com/FIHDDor.png
Gram Field Selected - https://i.imgur.com/rrDPZo2.png

Video of Form - https://screencast-o-matic.com/watch/cFnOqvDnAi


My current equation for the TSP field being selected, which works, is:
=IF($B$1="TSP",(IFERROR(VLOOKUP(A2,matrix,2,0),"")))*B2


When I select Gram from the drop down (B1) I'd like the value under Total to equal what I type in under the Gram cell. So 4 in B2 would output 4 in C2.

I'm not sure if this makes sense. The formula I had thought to use was the following, but it comes up with an error:
=IF($B$1="TSP",((IFERROR(VLOOKUP(A2,matrix,2,0),"")))*B2,),$B$1="Gram",B2*1))


Any help would be greatly appreciated!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Is there not a simple equation you can use in D2 to convert the result

I making number up now but something like = C2/300
 
Upvote 0
The goal is to make blend forms for all the different recipes we have. The first box (A1:C5) is where the recipe goes, then the totals are linked to another sheet to make a blend form for a larger quantity, say 25 lbs.

The issue is some recipes are by grams and others are by ******* measurements such as teaspoon. I figure it would be easiest to be able to switch back and forth using the drop down in B1.
 
Upvote 0
Solved!

I got it to work. I was thinking it needed to be two IF function; TSP=X, Gram=Y. However, I forgot that the IF function has a 'value_if_false' field. Noticing this I used the below formula.

=IF($B$1="TSP",(IFERROR(VLOOKUP(A2,matrix,2,0),""))*B2,B2)

Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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