+ Reply to Thread
Results 1 to 4 of 4

VBA Function not detecting all 3 decimal places in cells

  1. #1
    Registered User
    Join Date
    02-21-2012
    Location
    Harrisburg, PA
    MS-Off Ver
    Excel 2003
    Posts
    11

    VBA Function not detecting all 3 decimal places in cells

    I have a code where

    Please Login or Register  to view this content.
    this only seems to be picking up those cells with 3 decimal places which have a value like 12.224 not something which has a value like 12.228

    If I put in 12.228 it rounds it off to 12.23 automatically even though the actual value is 12.228

    Is there a way to avoid this?

    Thanks

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA Function not detecting all 3 decimal places in cells

    I'm a bit confused what you are trying to do but I'm guessing what you want is worksheetfunction.rounddown instead of round.

  3. #3
    Registered User
    Join Date
    02-21-2012
    Location
    Harrisburg, PA
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: VBA Function not detecting all 3 decimal places in cells

    if anyone enters more than 2 decimal places, a button check would check and highlight all the cells in a column which have more than 2 decimal places.

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA Function not detecting all 3 decimal places in cells

    Ok, so in your code, for 12.228, round(cell.value, 2) returns 12.23 and therefore 12.228 is not greater than round(Cell.value,2).

    What you can do is:
    if not cell.value = round(cell.value,2) then

    or use rounddown as per the previous post.

+ 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. Need to add decimal places to a data value inside of a function
    By Tyriel in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-09-2013, 11:54 AM
  2. showing cells to zero Decimal places
    By bumpty in forum Excel General
    Replies: 9
    Last Post: 10-10-2012, 06:47 AM
  3. [SOLVED] Function to round up if more than 2 decimal places
    By lauralizzy in forum Excel General
    Replies: 1
    Last Post: 06-28-2012, 09:30 AM
  4. Decimal places in linked cells
    By abousetta in forum Excel General
    Replies: 5
    Last Post: 02-16-2011, 08:53 AM
  5. Help with formating cells (decimal places)
    By madhead4000 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-03-2006, 04:40 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