+ Reply to Thread
Results 1 to 8 of 8

VBA code to remove everything after the decimal point

  1. #1
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    VBA code to remove everything after the decimal point

    Hi,
    I want a vba code that will remove everything after the decimal pooint in the entire workbook,without rounding the numbers.
    then remove all the formulas throughout the entire workbook that is present there.
    thanks for help.
    Last edited by fatalcore; 07-15-2011 at 12:56 AM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: VBA code to remove everything after the decimal point

    Hi Fatalcore,

    I suggest you remove the formulas first, since some of them may result in decimal numbers. The code below removes all formulas and then converts all numbers to integers (does not round). It loops through every worksheet in the workbook, too.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: VBA code to remove everything after the decimal point

    Hi Paul,
    Thanks for the code. The code works great in the first sheet only...It's not working in other sheets. Can you please help me on this.
    Thanks again.

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: VBA code to remove everything after the decimal point

    Try this slight change in Paul's code
    Please Login or Register  to view this content.
    It worked for me.
    Last edited by Mordred; 07-15-2011 at 12:04 AM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  5. #5
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: VBA code to remove everything after the decimal point

    Good catch, Mordy. (Do you mind if I call you Mordy?)


  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: VBA code to remove everything after the decimal point

    Quote Originally Posted by Paul View Post
    Good catch, Mordy. (Do you mind if I call you Mordy?)

    Just don't call me Shirly!

  7. #7
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: VBA code to remove everything after the decimal point

    Perfect !!!

    Awesome Friends....

    Marking as solved.

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA code to remove everything after the decimal point

    alternative:

    Please Login or Register  to view this content.



+ 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