+ Reply to Thread
Results 1 to 5 of 5

VB Code to truncate date to 2 decimal point

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to truncate date to 2 decimal point

    Hello:

    Please refer to attached file.

    I have data in cell B7:I39.
    i need a VB Code to truncate all data to 2 decimal point.

    Example : B7 = 32033.8545040666 which i need to be 32033.85
    and same with others.

    Let me Know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VB Code to truncate date to 2 decimal point

    Something like:
    Please Login or Register  to view this content.
    Select the range you want to truncate, run the code.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to truncate date to 2 decimal point

    Hello Olly:

    I am using below
    Please Login or Register  to view this content.
    Its giving Runtime Error '91'
    Ogject variable or With blockvariable not set

    Please help
    Riz

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VB Code to truncate date to 2 decimal point

    Okay, if you want to specify the range in the code (rather than working on a selection), then change that to:
    Please Login or Register  to view this content.
    Be aware that as written, this will always run on the active sheet. You may want to qualify the range with a worksheet reference - so that would look like:
    Please Login or Register  to view this content.
    Last edited by Olly; 04-08-2014 at 04:33 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to truncate date to 2 decimal point

    Hi Olly:

    Superb....Thanks a lot

    Riz

+ 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. Delevop a code to paste all values after decimal point
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-19-2012, 08:17 PM
  2. VBA code to remove everything after the decimal point
    By fatalcore in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-15-2011, 03:31 AM
  3. Replies: 3
    Last Post: 03-18-2006, 02:25 PM
  4. [SOLVED] truncate the yaxis if one data point is MUCH higher than the rest
    By steve in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-15-2005, 12:05 AM
  5. [SOLVED] FIXED 2 DECIMAL PLACES, MUST ENTER ALL ZEROES AFTER DECIMAL POINT.
    By SUKYKITTY in forum Excel General
    Replies: 3
    Last Post: 07-06-2005, 09:05 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