+ Reply to Thread
Results 1 to 14 of 14

vba code for converting vulgar fractions to decimals

  1. #1
    Registered User
    Join Date
    12-28-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003
    Posts
    54

    vba code for converting vulgar fractions to decimals

    Hello,

    I was wondering if there is a vb code that can be made to convert vulgar fractions (ie. ½) to a decimal. I wouldn't mind doing manually if I had only one or two to change, but I have quite a few and if a vb code can locate and change any vulgar fraction that is on my excel spread sheet to a decimal even if there is a whole number next to it (ie. 1½) that would be sweet.

    CheerZ!
    Wyldjokre69

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: vba code for converting vulgar fractions to decimals

    Hi
    Have a look at this link which may help.
    Good luck.
    Tony

  3. #3
    Registered User
    Join Date
    12-28-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003
    Posts
    54

    Re: vba code for converting vulgar fractions to decimals

    Sorry Tony, what link?
    Wyldjokre69

  4. #4
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: vba code for converting vulgar fractions to decimals


  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: vba code for converting vulgar fractions to decimals

    Maybe:

    Please Login or Register  to view this content.
    Would work for Column A.

  6. #6
    Registered User
    Join Date
    12-28-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003
    Posts
    54

    Re: vba code for converting vulgar fractions to decimals

    Thanks John, but unfortunately, all it did was turn my whole numbers into numbers with decimal placements in them. I was hoping to have the code change only the vulgar fractions into decimals leaving the whole numbers intact.
    Wyldjokre69

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: vba code for converting vulgar fractions to decimals

    Can you attach a sample file? To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

  8. #8
    Registered User
    Join Date
    12-28-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003
    Posts
    54

    Re: vba code for converting vulgar fractions to decimals

    Hey John,

    Here is a sample worksheet and highlighted in yellow is the area of my problem. Thanks for taking the time.

    CheerZ!
    Wyldjokre69

    SAMPLE WORKSHEET.xlsm

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: vba code for converting vulgar fractions to decimals

    as you have used a special character for ½ can you not simply do a Find & Replace

    Find: ½
    Replace: .5
    Cheers
    Andy
    www.andypope.info

  10. #10
    Registered User
    Join Date
    12-28-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003
    Posts
    54

    Re: vba code for converting vulgar fractions to decimals

    Hey Andy,

    Yes. That is what I'm doing at the moment, it is quick and everything, but I figured there would be a way to just have it done by code.

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: vba code for converting vulgar fractions to decimals

    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: vba code for converting vulgar fractions to decimals

    My suggestion wouldn't work on this file because of the special characters. It assume that a fraction such as 1/2 would produce a Len of 3, whereas the fractions on your worksheet produces a Len of 1. Maybe you should try Andy's suggestion.

  13. #13
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: vba code for converting vulgar fractions to decimals

    Modified:

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    08-22-2014
    Location
    Point of Rocks
    MS-Off Ver
    2013
    Posts
    2

    Re: vba code for converting vulgar fractions to decimals

    =--if(iserror(find("'",ah1065)),0,if(countif(ah1065,"*/*")*(countif(ah1065,"*'")>0),"0","")&left(ah1065,find("'",ah1065)-1))+if(iserror(find("""",ah1065)),0,--(if(countif(ah1065,"*/*")*(countif(ah1065,"* */*")=0),"0 ","")&substitute(mid(ah1065,if(iserror(find("-",ah1065)),1,find("-",ah1065)+1),255),"""","")))/12

+ 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. Converting fractions to decimals
    By Millertime31 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-24-2011, 04:56 PM
  2. fractions and decimals!
    By AmyTaylor in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-05-2006, 07:25 PM
  3. [SOLVED] converting decimals to fractions
    By jason2444 in forum Excel General
    Replies: 5
    Last Post: 01-19-2006, 11:40 PM
  4. converting decimals to fractions
    By jason2444 in forum Excel General
    Replies: 1
    Last Post: 01-19-2006, 10:00 PM
  5. Converting Decimal Fractions to Fractions of a Specified Number
    By ExcelTip in forum Tips and Tutorials
    Replies: 0
    Last Post: 08-29-2005, 11:09 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