UOM Conversion Formula

tecwdw

New Member
Joined
Sep 21, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have an imported csv file in Excel with a field formatted as "general" that looks like 2 gal 1.47 fl oz
I need a formula that will convert this field to the total number gallons - which in this example would be 2.01148 total gallons.

I'm sort of stumped on how to extract the individual pieces of the field in order to calculate the conversion. I know the alpha characters need removed first probably.

This field may also look like 3.84 gal (with no oz designation)
or 104.96 fl oz (with no gal designation)

Appreciate any suggestions as this is a tedious manual task right now for me.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Try this:

Mr excel questions 63.xlsm
ABC
1
22 gal 1.47 fl oz2.011484375
33.84 gal3.84
4104.96 fl oz0.82
5
tecwdw
Cell Formulas
RangeFormula
B2:B3B2=IF(ISNUMBER(FIND("GAL",UPPER(A2))), TEXTBEFORE(A2," gal",1,1,0,0)+IF(ISNUMBER(FIND("FL",UPPER(A2))),TEXTBEFORE(TEXTAFTER(A2,"gal ",1,1,0)," fl",1,1,0,0),0)/128,1*TEXTBEFORE(A2," fl",1,1,1,0))
B4B4=IF(ISNUMBER(FIND("GAL",UPPER(A4))), TEXTBEFORE(A4," gal",1,1,0,0)+IF(ISNUMBER(FIND("FL",UPPER(A4))),TEXTBEFORE(TEXTAFTER(A4,"gal ",1,1,0)," fl",1,1,0,0),0)/128,1*TEXTBEFORE(A4," fl",1,1,1,0)/128)
 
Upvote 0
You did not specify type of gallons. Edit number for conversion of oz if necessary for your jurisdiction.

another alternative

T202309a.xlsm
AC
1
22 gal 1.47 fl oz2.011484
33.84 gal3.84
4104.96 fl oz0.82
5
1g
Cell Formulas
RangeFormula
C2:C4C2=IFERROR(TEXTBEFORE(A2," g")+IFERROR(TEXTBEFORE(TEXTAFTER(A2,"gal ")," f")/128,0),TEXTBEFORE(A2," f")/128)
 
Last edited:
Upvote 0
You did not specify type of gallons. Edit number for conversion of oz if necessary for your jurisdiction.

another alternative

T202309a.xlsm
AC
1
22 gal 1.47 fl oz2.011484
33.84 gal3.84
4104.96 fl oz0.82
5
1g
Cell Formulas
RangeFormula
C2:C4C2=IFERROR(TEXTBEFORE(A2," g")+IFERROR(TEXTBEFORE(TEXTAFTER(A2,"gal ")," f")/128,0),TEXTBEFORE(A2," f")/128)
Perfect! Thank you, Dave and awoohaw, for saving me so much time going forward!!!!
 
Upvote 0

Forum statistics

Threads
1,223,327
Messages
6,171,486
Members
452,407
Latest member
Broken Calculator

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