+ Reply to Thread
Results 1 to 6 of 6

Text Fraction to formula MK2

  1. #1
    Registered User
    Join Date
    08-20-2018
    Location
    Mass, USA
    MS-Off Ver
    MS365 version 2303
    Posts
    28

    Unhappy Text Fraction to formula MK2

    I have a spreadsheet with text based fraction values. I would like to convert these fractions into decimals in an adjacent column. I asked a similar question the other day, but I'm still having issues.
    Basically, I am wondering if there is an easy way to convert 1/8 in B2 to =1/8 in B3.

    The first rows of my text column looks like this.

    2
    1-1/4
    1/8
    9/32

    where 1-1/4 represents 1+(1/4)

    As you can see, there are a few different styles of values. Any ideas?
    Last edited by Ian.Lance; 08-30-2018 at 02:29 PM.

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Text Fraction to formula MK2

    This works on your sample that you shared in post #1:

    =IFERROR(LEFT(SUBSTITUTE(B2,"-"," "),FIND("/",B2)-1)/MID(B2,FIND("/",B2)+1,LEN(B2)),SUBSTITUTE(B2,"-"," ")+0)

  3. #3
    Registered User
    Join Date
    08-20-2018
    Location
    Mass, USA
    MS-Off Ver
    MS365 version 2303
    Posts
    28

    Re: Text Fraction to formula MK2

    Awesome, Thanks! I forgot about IFERROR

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Text Fraction to formula MK2

    What was wrong with the suggestion from MrShorty?
    https://www.excelforum.com/excel-gen...al-values.html

    (and you really should have continued on that thread, but we will let it slide this time )

    63's is similar to mine in your other thread...
    Try this, and format as Fraction...
    =LEFT(B2,FIND("/",B2)-1)/MID(B2,FIND("/",B2)+1,99)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Text Fraction to formula MK2

    Link to earlier thread: https://www.excelforum.com/excel-gen...al-values.html

    I would still be inclined to use the VALUE() function, you just need to get the text into a format like "a b/c", or otherwise identify the different forms the text can take. (I will mention that, if I had any control over data entry, I would force the data entry into a form that is easier to work with). As I explained in the other thread, the previous solution assumed that all entries were "b/c" entries and that there would never be mixed number entries. Now we see that mixed numbers are possible. Before getting too far into this, are these representative of all possible entries, or are there other considerations? Does a hyphen "-" always separate mixed numbers, or can other characters be used there?

    With the 4 example values, something like this should work:
    1) Use a SUBSTITUTE() function to get rid of the hyphen and replace it with a space SUBSTITUTE(B2,"-"," ")
    2) Test if Excel wants to convert the value into a date, and act accordingly using an IF() function IF(VALUE(SUBSTITUTE(B2,"-"," "))>400,"0 "&B2,SUBSTITUTE(B2,"-"," ")). The 400 is just a value larger than anything you ever expect to get, that will also be smaller than any date serial number you may get.
    3) Nest that inside of a VALUE() function. =VALUE(IF(VALUE(SUBSTITUTE(B2,"-"," "))>400,"0 "&B2,SUBSTITUTE(B2,"-"," ")))

    Assuming I got all the parentheses matched up right, that works for the four examples you give. Will that work for you?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Forum Contributor
    Join Date
    10-30-2003
    Location
    Singapore
    MS-Off Ver
    Excel 2019
    Posts
    197

    Re: Text Fraction to formula MK2

    Or………………..

    =-IFERROR(-("0 "&B2),-SUBSTITUTE(B2,"-"," "))

    Regards
    Bosco

+ 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] Add Text prior to fraction
    By colarguns in forum Excel General
    Replies: 16
    Last Post: 07-14-2018, 06:14 AM
  2. Refinancing one fraction selling the other fraction in a context of variable price
    By General Patton in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-18-2017, 07:55 AM
  3. Replies: 3
    Last Post: 09-04-2013, 01:56 AM
  4. Replies: 10
    Last Post: 06-11-2013, 06:11 PM
  5. Import fraction from text file
    By Rock_boy in forum Excel General
    Replies: 2
    Last Post: 03-26-2012, 05:05 PM
  6. Replies: 7
    Last Post: 12-17-2010, 04:23 PM
  7. convert fraction to text
    By adam2308 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-03-2009, 03:23 PM

Tags for this Thread

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