An Alternative Approach

dwgnome

Active Member
Joined
Dec 18, 2005
Messages
441
Looking to see if there is a more efficient formula for the following:

Code:
=IF(F22="pint",CONVERT(E22,"pt","gal"),IF(F22="quart",CONVERT(E22,"qt","gal"),IF(F22="liter",CONVERT(E22,"l","gal"),IF(F22="fluid",CONVERT(E22,"oz","gal"),IF(F22="cc",CONVERT(E22,"ml","gal"),CONVERT(E22,F22,"gal"))))))

Looking to expand to include additional conversions so naturally I may run into nested IF maximum.

Excel 2010.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You could make a lookup table with the full words in one column, and the conversion versions in another.

Try something like this


Unknown
EFGHIJK
225quart1.25pintpt
23quartqt
24literl
25fluidoz
26ccml
Sheet1
Cell Formulas
RangeFormula
G22=CONVERT(E22,IFERROR(VLOOKUP(F22,$J$22:$K$26,2,0),F22),"gal")
 
Upvote 0
If you did not want to maintain a table on a worksheet, you could embed the table inside your formula...

=CONVERT(E22,IFERROR(INDEX({"pt","qt","l","oz","ml"},MATCH(F22,{"pint","quart","liter","fluid","cc"},0)),F22),"gal")
 
Upvote 0
Thank you both for your responses. They both worked perfectly - much cleaner and more versatile.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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