+ Reply to Thread
Results 1 to 7 of 7

Least Significant Digit, 0, is not captured by a VBA read

  1. #1
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    178

    Least Significant Digit, 0, is not captured by a VBA read

    A single piece of Data in a worksheet cell is presented as 179.5950

    It presents in this fashion as I have formatted the presentation in the worksheet as a number with four decimal places.

    the above formatting is ONLY for presentation. I believe the data is stored as 179.59500000000 for a total of 15 alpha numeric characters.

    But when VBA code brings in the above stored number with all its zeros, excel truncates the trailing zeros (thinking it knows best instead of allowing me to tell it how many trailing zeros I desire) and thus hands me a number without any trailing zeros.

    Thus formatting data in a worksheet permits me to preserve the presentation of trailing zeros but the data is STORED in excel without preserving the trailing zeros as I have defined in presentation.

    Some of you, who work with numbers in a traditional sense will express that this is not a problem. After all there is no mathematical difference between 179.595 and 179.5950

    But there is a difference in two totally different ways.

    first engineers know that the number of decimal places conveys precision.
    Thus keeping the trailing zero conveys that the data is good to the thousandths(in this example) of a unit of measurement. Truncating removes information important to an engineer but not to a pure mathematician.

    Secondly, A number that appears to be "one" number may in fact be a number that stores multiple numbers. In my case, an extremely well known surveying company sells Total Stations (a surveying instrument) which outputs degrees, minutes, seconds for an angle as a single number: DDD.MMSS It is a number that stores three pieces of data

    In the example I am grappling with, 179.5950 is a number that expects to be decoded as:
    Degrees = 179
    Minutes = 59
    Seconds = 50

    But because excel hands the code a number which truncates trailing edges, the decoding becomes
    Degrees = 179
    Minutes = 59
    Seconds = 5

    The results are unacceptable.

    This problem is NOT a VBA coding problem but instead requires understanding how excel retrieves stored data (different from the presented data) to VBA code. There is no need to present code(though I am willing). This is a more fundamental problem.

    Please offer insight into this problem and possible solutions.

    Thank you
    Last edited by whburling; 04-16-2017 at 01:58 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,598

    Re: Least Significant Digit, 0, is not captured by a VBA read

    Suggest you post the function so that it can be tested and modified.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    178

    Re: Least Significant Digit, 0, is not captured by a VBA read

    HI Trevor,

    I completely re-wrote the problem I am facing so that you can see that this problem is not due to code but to do my not understanding fundamental operations of excel and vba.

    If you can not understand what I am asking, please let me know and I will try another way to present the problem.

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Least Significant Digit, 0, is not captured by a VBA read

    thy this with the activecell that has the value of 179.5950

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,598

    Re: Least Significant Digit, 0, is not captured by a VBA read

    Try:

    Please Login or Register  to view this content.

    See the example.
    Attached Files Attached Files

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,598

    Re: Least Significant Digit, 0, is not captured by a VBA read

    Note: this was for testing purposes and is redundant:

    Please Login or Register  to view this content.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,598

    Re: Least Significant Digit, 0, is not captured by a VBA read

    Thanks for the rep.

+ 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. [SOLVED] List box to read input range rather than random digit
    By kosherboy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-02-2014, 11:19 AM
  2. [SOLVED] LOTTERY FILTER#4, Find if 1 Digit Sum of 2 Digit or 3 Digit, Single Cell w/ dash
    By david gonzalez in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-08-2014, 12:57 AM
  3. Excel 2008 : Additional cells captured when only one chosen
    By Katydid6387 in forum Excel General
    Replies: 2
    Last Post: 07-05-2012, 05:19 PM
  4. Conditional Data to be captured
    By kasimdaruwala in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-14-2011, 12:53 AM
  5. Output results not being captured
    By ayesha in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-09-2009, 03:45 PM
  6. Insert Rows after captured Data
    By zahus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-18-2009, 09:59 AM
  7. macros for read barcode digit and find
    By the_power in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-21-2007, 11:10 AM

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