+ Reply to Thread
Results 1 to 11 of 11

Fractions to numbers?

Hybrid View

  1. #1
    Registered User
    Join Date
    07-22-2008
    Location
    auburn
    Posts
    74

    Fractions to numbers?

    I have some numbers that I've imported from the internet. Some of them contain fractions (i.e. 7 1/2) where the 1/2 is a single fraction character. Is there a function I can use to automatically turn these fraction characters into numbers when they're imported to excel via web query? Thanks for your help!
    Last edited by NBVC; 08-07-2009 at 04:18 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Fractions to numbers?

    Can't guarantee it.. but if you post an actual sample sheet with these, we can check for you.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Fractions to numbers?

    I set a cell to "Number" format with 3 decimal places, then entered a random fraction of, 7 63/78. upon exiting the cell it automatically converted to decimal format, 7.808.

    HTH
    Regards

    Rick
    Win10, Office 365

  4. #4
    Registered User
    Join Date
    07-22-2008
    Location
    auburn
    Posts
    74

    Re: Fractions to numbers?

    I uploaded a sample spreadsheet containing the fractions I'm talking about and attached it to this post... thanks.
    Attached Files Attached Files

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Fractions to numbers?

    A formula like this might work:

    =SUBSTITUTE(SUBSTITUTE(A3," ½",".5")," ¼",".25")+0

    this is a nested Substitute() formula, that replace " " ½" with a ".5" and " ¼" with a ".25" note the space before the fraction...

    you can nest several of these function to replace other common fractions..

    The +0 outside the entire function converts the text number to an actual number

  6. #6
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Fractions to numbers?

    Side note, am I missing something here? Why couldn't you format the cells to numbers with a decimal place setting?
    That would take any value entered and convert to whole or decimal.
    If set to two decimal places:
    "1" = 1.00
    "1 1/4" = 1.25
    "25/64" = 0.39 (0.390625)
    etc.

  7. #7
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Fractions to numbers?

    Never mind!
    sub BrainCellsActive
    Loop
        BrainCells.Activate
        Think
    Loop Forever
    End sub

  8. #8
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481

    Re: Fractions to numbers?

    Rick,

    You forgot an error handler in your code.
    What would happen if BrainCells.Activate could not execute?

    Would we be stuck in debug mode not ever reaching the Think command?

  9. #9
    Registered User
    Join Date
    07-22-2008
    Location
    auburn
    Posts
    74

    Re: Fractions to numbers?

    Yeah, that should work. My problem was I can't type in the 1/2 in fractional character form but I figured out I can just cut and paste it... thanks a lot!

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Fractions to numbers?

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  11. #11
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Fractions to numbers?

    sub BrainCellsActive
    OnError Goto Bar
    Loop
        BrainCells.Activate
        Think
    Loop Forever
    Bar:
    With Bar.Drink
    If Bar.Drunk <> True Then
    Loop ForHours
    Else
    BrainCells.DeActivate
    End If
    End with
    End sub
    That help?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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