+ Reply to Thread
Results 1 to 16 of 16

Formatting fraction "1 3/4" as "7/4"

  1. #1
    Registered User
    Join Date
    11-11-2010
    Location
    Zwolle, NL
    MS-Off Ver
    Excel 2003
    Posts
    7

    Unhappy Formatting fraction "1 3/4" as "7/4"

    Hi all,
    I'm new to this forum and I just signed up because I couldn't find a way to solve this issue:
    I am making a list of roughly 15000 articles with dimensions and all, however, some dimensions are Imperial. these dimensions are written as EG: 1 1/4, 1 1/2 etc.
    everything works as planned but the problem is that in my product managemnt system one field is prescribed to contain these fractions in the following form: 5/4, 3/2 etc.

    Is there any way to automate this field by using either functions or formatting options?
    in PHP I already made an example of what the script should do:

    $fraction = "1 3/4";
    $whole = explode(" ", $fraction);
    $tn = explode("/", $whole[1]);
    $w = $whole[0];
    $t = $tn[0];
    $n = $tn[1];
    $new = (($w * $n)+ $t)."/".$n;
    echo "Old: ".$fraction."<br />";
    echo "New: ".$new;

    in layman's terms:

    2 1/4 ---> A= 2, B= 1, C= 4
    Newfraction = ((A * C)+ B)/C = 9/4

    I could use the LEFT() and COUNT() functions intertwined with each other (to seperate the numbers) but this would make an highly unstable and large formula.. It sjhould be easier in my opinion...

    I hope you can help me!
    Thanks

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Formatting fraction "1 3/4" as "7/4"

    You could use this (developed), but it will return a string, that might lead to further problems.

    =INT(A2/0.25)&"/4"

    Hope this helps
    Last edited by Marcol; 11-11-2010 at 06:04 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Registered User
    Join Date
    11-11-2010
    Location
    Zwolle, NL
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Formatting fraction "1 3/4" as "7/4"

    FIXED!
    if N55 = 1 1/4
    output = 5/4

    if N55 = 3/4
    output = 3/4

    if N55 = 580/900
    output = #value!
    there are some errors in it (because of the length and find vars, but it works for now)

    =IF(LEN(N55)>=5;(MID(N55;1;FIND(" ";N55))*MID(N55;LEN(N55);1))+MID(N55;FIND("/";N55)-1;1)&"/"&MID(N55;LEN(N55);1);N55)

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Formatting fraction "1 3/4" as "7/4"

    if its only 1/4 and 1/2 AND the input cell is formated as text
    =IF(RIGHT(A1)="4",A1/0.25&"/4",A1/0.5&"/2")
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Registered User
    Join Date
    11-11-2010
    Location
    Zwolle, NL
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Formatting fraction "1 3/4" as "7/4"

    Yes I agree, but I cannot guarantee that there will opnly be those two values, these are the two stated in my little part in my excel file, but they are dimensions, thus I should be aware that more options are possible.
    and also, the fields are formatted as fractions up to two digits

  6. #6
    Valued Forum Contributor
    Join Date
    10-17-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013, 2016, 2019, 365
    Posts
    294

    Re: Formatting fraction "1 3/4" as "7/4"

    Is it text or a value?

    If it's a value, then obviously 1 3/4 is 1.75. Just change the number formatting to a custom format of ##/## and it'll display correctly.

  7. #7
    Registered User
    Join Date
    11-11-2010
    Location
    Zwolle, NL
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Formatting fraction "1 3/4" as "7/4"

    It is formatted as a value (fraction)
    even when I reformat it as what you stated (which doesnt work, just tried it) the field in which the value resides should harbor that formatting as well, this would make something as ######DP-##/##-R-GD
    .. but I got it to work now

    see post number 2, however, a more elegant solution is always great to have! :D

  8. #8
    Valued Forum Contributor
    Join Date
    10-17-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013, 2016, 2019, 365
    Posts
    294

    Re: Formatting fraction "1 3/4" as "7/4"

    Dunno why it doesn't work on yours - works on mine! hash hash slash hash hash. Sounds good anyway....
    If you want to add text, also try ="DP-"&TEXT(A1,"##/##")&"-R-GD"

  9. #9
    Registered User
    Join Date
    11-11-2010
    Location
    Zwolle, NL
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Formatting fraction "1 3/4" as "7/4"

    Quote Originally Posted by outofthehat View Post
    Dunno why it doesn't work on yours - works on mine! hash hash slash hash hash. Sounds good anyway....
    If you want to add text, also try ="DP-"&TEXT(A1,"##/##")&"-R-GD"
    lol oh ****! :o
    that does work, Now I'm feeling like an idiot, and I want to bitchslap Microsoft for demolishing the format cell function. that is indeed a text field, but who cares, it works. thanks!

  10. #10
    Valued Forum Contributor
    Join Date
    10-17-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013, 2016, 2019, 365
    Posts
    294

    Re: Formatting fraction "1 3/4" as "7/4"

    Glad to help. If you're happy, please mark your thread as solved. Ta.

  11. #11
    Registered User
    Join Date
    11-11-2010
    Location
    Zwolle, NL
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Formatting fraction "1 3/4" as "7/4"

    I know have a frankenstein of formulas in that part of the sheet, I might just dive into it and create a better function as a combination of all of your suggestions.
    Thanks! and the marking will [NOT] happen right now
    Last edited by Pioni; 11-11-2010 at 06:35 AM. Reason: I don't know how to mark as solved, I saw it when i started the thread though.. nasty...

  12. #12
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Formatting fraction "1 3/4" as "7/4"

    This is a bit messy but seems to work
    Please Login or Register  to view this content.

    Hope this helps

    [EDIT]
    This is a classic way to give ones' self a red face, I even built outofthehats' solution in to the formula SIX times!!!!
    There are none as blind as them that cannot see.
    Attached Files Attached Files
    Last edited by Marcol; 11-11-2010 at 07:00 AM. Reason: To highlight my stupidity

  13. #13
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Formatting fraction "1 3/4" as "7/4"

    Or

    =if(a15=0,"",int(int(a15)*right(text(a15,"0000/0000"),4))+left(text(mod(a15,1),"0000/0000"),4)&"/"&--right(text(a15,"0000/0000"),4))
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  14. #14
    Registered User
    Join Date
    11-11-2010
    Location
    Zwolle, NL
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Formatting fraction "1 3/4" as "7/4"

    Wow Darren,
    that's it exactly!
    Now I will only have to add an if statement to determine if the value even is a fraction.

    I was sceptical this morning but I guess excel isn't as bad as I thought this morning!

  15. #15
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Formatting fraction "1 3/4" as "7/4"

    Wouldn't this do the same, using outofthehat's formatting but within a text function?

    =TEXT(A15,"#/#")
    Audere est facere

  16. #16
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Formatting fraction "1 3/4" as "7/4"

    Lol funny you should say that, I kept thinking it wasnt right to do all that work and I ended up with the same, but after reading the post (I looked at the last comment, not the original) I figured he had already been answered!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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