+ Reply to Thread
Results 1 to 6 of 6

Use the first 3 decimals in stead of rounding

  1. #1
    Forum Contributor
    Join Date
    06-29-2005
    Posts
    201

    Use the first 3 decimals in stead of rounding

    Hi all

    I an wondering if there is in VBA an easy way (formula?) to use the first 3 decimals and NOT round these up of down.

    e.g: 1.2345 should become 1.234 and not 1.235

    In the same way:
    1 should be 1.000
    11.1 should be 1.100
    123.23456 should be 123.234
    1.234567 should be 1.234 etc

    I have thought about a detour and recalculate the decimals * 1000 and then left(...,3) but I hope there is an easier way out?

    Can anyone help?

    Thanks in advance
    Hein

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Use the first 3 decimals in stead of rounding

    Assuming x is your number,
    CLng(x * 1000)/1000
    shoudl give you what you want.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    09-27-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    86

    Re: Use the first 3 decimals in stead of rounding

    Hi Hein,

    Suppose you data is in A2 cell below is the VBA Code also updating the formula for your reference.

    Please Login or Register  to view this content.
    Regards,
    lokicl

  4. #4
    Registered User
    Join Date
    09-27-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    86

    Re: Use the first 3 decimals in stead of rounding

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

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    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


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  5. #5
    Forum Contributor
    Join Date
    06-29-2005
    Posts
    201

    Re: Use the first 3 decimals in stead of rounding

    Thank you Rory (again!)

    I didn't know about this CLng - feature but it works
    I thought there had to be an easier way to achieve my goal, and there was

    Thanks again
    Hein

  6. #6
    Forum Contributor
    Join Date
    06-29-2005
    Posts
    201

    Re: Use the first 3 decimals in stead of rounding

    Hi lokicl

    Thank for your contribution, but as you can see from my reply to romperstomper his solution works for me.
    I will copy and save your suggestion in my suggestion file and use it when appropriate
    Thanks again
    Hein

+ 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. Rounding decimals below and above 0,50
    By Hitch75 in forum Excel General
    Replies: 4
    Last Post: 09-23-2010, 08:15 AM
  2. Rounding decimals
    By Russell719 in forum Excel General
    Replies: 2
    Last Post: 08-24-2007, 12:09 PM
  3. [SOLVED] Rounding Up Decimals
    By Lilbit in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-04-2006, 04:45 PM
  4. Rounding Decimals
    By Jim May in forum Excel General
    Replies: 8
    Last Post: 11-07-2005, 02:10 PM
  5. [SOLVED] Re: Rounding with no Decimals...
    By Karthik in forum Excel General
    Replies: 1
    Last Post: 07-29-2005, 02:06 PM

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