+ Reply to Thread
Results 1 to 6 of 6

Convert Feet - Inch - Inch Fraction string into numerical value

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-02-2014
    Location
    usa
    MS-Off Ver
    MS 365
    Posts
    596

    Convert Feet - Inch - Inch Fraction string into numerical value

    Hello,
    I have a string in a cell which looks like:
    5’ – 4”
    Or,
    11’-6 11/16”
    Or,
    2’- 0 1/8”
    And so forth... (values might be different every time)
    I need to pull out the numerical values from these strings in order to operate and get the arithmetical values of those measurements.
    Here is what I am struggling with:
    1. Get the numerical value of the string preceding the “ ‘ “ sign.
    2. Get a message box : String contains “/” sign when there is one.
    3. Get the numerical value between the “-“ sign and the “ “ “ sign when no “/” exists
    4. Get the numerical value between the “-“ sign and the fraction following the last gap
    5. Get the numerical value of the fraction following the last gap, preceding the " " " sign when “/” exists.
    Or, any other idea to extract the numerical value of the string , would be appreciated.
    Perhaps there is a routine already for this?
    Thanks

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Convert Feet - Inch - Inch Fraction string into numerical value

    Does 5'-4" represent 64 inches (5 ft. 4 inches) or is it 56 inches (5 ft. less 4 inches)?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Contributor
    Join Date
    03-02-2014
    Location
    usa
    MS-Off Ver
    MS 365
    Posts
    596

    Re: Convert Feet - Inch - Inch Fraction string into numerical value

    5'-4" is 64"
    The "-" sign is just a formatting / marker to separate the Feet from Inches
    Thanks

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Convert Feet - Inch - Inch Fraction string into numerical value

    This UDF will do what you want.
    Function FInch2Inch(aString As String) As Double
        Dim footPart As Double
        Dim strIn As String
        If Not (aString Like "*'*") Then aString = "'" & aString
        aString = Replace(aString, "-", vbNullString)
        footPart = Val(aString)
        
        FInch2Inch = 12 * footPart + Evaluate(Replace(Split(aString, "'")(1), """", vbNullString))
    End Function

  5. #5
    Forum Contributor
    Join Date
    03-02-2014
    Location
    usa
    MS-Off Ver
    MS 365
    Posts
    596

    Re: Convert Feet - Inch - Inch Fraction string into numerical value

    mikereickson,
    Thanks for the response; I am not quite familiar with UDF.
    How do I call the function in my subroutine?

    Is it something like
    NumValue = FInch2Inch(Activecell.value) ?
    Thanks

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Convert Feet - Inch - Inch Fraction string into numerical value

    The argument passed to FInch2Inch is a string, and the value it returns is a type double.


    If you have 5'-6 3/4" in A1, a cell with the formula =FInch2Inch(A1) will return 66.75

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] formula to convert decimal feet to feet inch sixteenths
    By tv in forum Excel General
    Replies: 13
    Last Post: 06-02-2025, 09:14 AM
  2. Replies: 3
    Last Post: 06-01-2015, 12:48 AM
  3. Converting feet & inch demensions to inch only in excell
    By sgmgrider in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-20-2015, 08:10 PM
  4. Formula to round value (in feet) up to nearest 1/16 inch.
    By devpatel85 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-26-2013, 09:37 AM
  5. [SOLVED] Decimal to feet/inch/fractional inch conversion
    By Rodney Sergent in forum Excel General
    Replies: 1
    Last Post: 08-10-2006, 10:50 PM
  6. Professional engineering graph sheets 10 x 10/inch and 8 x 8/inch
    By Fugro-Karen in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-05-2006, 08:40 AM
  7. [SOLVED] convert decimal to inch & fraction
    By davepatrob in forum Excel General
    Replies: 1
    Last Post: 12-31-2005, 01:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1