+ Reply to Thread
Results 1 to 4 of 4

VBA to truncate entry data in Excel does not work on some numbers!

  1. #1
    Registered User
    Join Date
    07-24-2023
    Location
    Los Angeles
    MS-Off Ver
    Mac
    Posts
    1

    Question VBA to truncate entry data in Excel does not work on some numbers!

    I use this piece VBA code to truncate the input numbers in Excel but in some cases it still round the number rather than truncating them. When I try some specific numbers, it does NOT work. The examples I found are: 1.11116, 17.84116.

    I use this piece VBA code to truncate the input numbers in Excel but in some cases it still round the number rather than truncating them. When I try some specific numbers, it does NOT work. The examples I found are: 1.11116, 17.84116.

    These are the only numbers I came across that the code does not work on. Both end with a 6, but there is no pattern to the issue.

    This is the code:

    Please Login or Register  to view this content.
    Does anyone have any ideas why this is happening and how to fix it? Thanks.
    Last edited by AliGW; 07-25-2023 at 02:22 AM. Reason: Code tags added.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,257

    Re: VBA to truncate entry data in Excel does not work on some numbers!

    In the absence of any expecte results, try:

    Please Login or Register  to view this content.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: VBA to truncate entry data in Excel does not work on some numbers!

    I haven't tested it exhaustively, but this seems to work:
    Please Login or Register  to view this content.
    I removed the error-handling, assuming it was left over from development.
    Last edited by leelnich; 07-25-2023 at 02:30 AM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,247

    Re: VBA to truncate entry data in Excel does not work on some numbers!

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new here, I have done it for you this time.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. Replies: 6
    Last Post: 04-12-2023, 11:28 AM
  2. [SOLVED] Data Entry from one excel workbook to several excel work sheets "Else without if" Error
    By rajtar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-12-2016, 10:49 AM
  3. How do I import an XML file into Excel using Macros to ensure none of the data is truncate
    By kiran_rangarajan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2015, 11:06 AM
  4. How to truncate numbers on right side of alphabets
    By Tai Chi in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-20-2015, 08:25 PM
  5. Need A data entry form to save the data in several work sheets
    By nilesh_urkude in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2013, 12:25 AM
  6. [SOLVED] Excel Worksheet Subtotals Data Truncate
    By tomwashere2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-15-2005, 10:05 PM

Tags for this Thread

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