+ Reply to Thread
Results 1 to 7 of 7

Set cell to long number value without rounding

  1. #1
    Registered User
    Join Date
    09-24-2017
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    15

    Set cell to long number value without rounding

    Hi,

    I'm sure I'm just missing something obvious but I have a raw data set, which I'm putting into a dictionary.

    One of the values is an ID, which can (but not always) be a 20 digit number.

    I've got it into the dictionary by defining the item as variant, and it's being stored as "Variant/String" and it stored in the dictionary without rounding - which is perfect.

    However I'm then trying to get those values into the spreadsheet, by looping through the dictionary and setting certain cells equal to certain values, but every time I try to put this ID into Excel, it rounds after 10 digits.

    Can someone please help?

    I'm trying:

    Cells([row],[column]) = DictionaryEntry.ID

    And I'm totally lost.

    Thanks in advance!

    ---------

    Edit: Probably not the smartest solution but I just went in a formatted the relevant columns a text field prior to putting the values in. Thanks for everyone's help
    Last edited by AB91; 12-23-2018 at 09:03 PM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Set cell to long number value without rounding

    I think that you will need to format the cell as text.

    I depends on what you want to do with the number.


    https://support.microsoft.com/en-gb/...ectly-in-excel
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Set cell to long number value without rounding

    https://support.microsoft.com/en-us/...sults-in-excel
    "In the case of Excel, although Excel can store numbers from 1.79769313486232E308 to 2.2250738585072E-308, it can only do so within 15 digits of precision. This limitation is a direct result of strictly following the IEEE 754 specification and is not a limitation of Excel."

    And also:
    https://en.wikipedia.org/wiki/Numeri...icrosoft_Excel
    https://superuser.com/questions/3739...igits-in-excel
    https://answers.microsoft.com/en-us/...4-f9bb412c9039
    etc.

  4. #4
    Registered User
    Join Date
    09-24-2017
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    15

    Re: Set cell to long number value without rounding

    It's being stored correctly in the VBA dictionary as a string/variant, but I can't get it to be put into a cell as a text field - any advice there??

  5. #5
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Set cell to long number value without rounding

    1. Excel limitations
    2. Vba is just an add-on to excel
    3. How do you change the number into text at the vba level before you copy it into the cell ? - show the methodology

  6. #6
    Registered User
    Join Date
    09-24-2017
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    15

    Re: Set cell to long number value without rounding

    Hi Porucha - thanks for your help, I'm just not that good at VBA unfortunately.

    So the long number is stored as a text field in the source data.
    In the dictionary, I've assigned it to a variant field by "=[cell].Text"
    Then in the dictionary, it's being stored as the full number, as a Variant/String (based on looking at the Locals window when it runs)
    So then all I'm trying to do is put that text value into a cell, which I'm failing at. If that's an Excel limitation, then I'll figure something else out, but as it's a text/string I assume there is a way to work it

  7. #7
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Set cell to long number value without rounding

    You can do experiments:
    Please Login or Register  to view this content.
    Attached Images Attached Images

+ 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 up a cell to a whole number
    By bjkh1508 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-06-2016, 11:07 AM
  2. [SOLVED] Cell with text and number, not rounding to closest full number
    By cblp in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-03-2014, 07:51 PM
  3. [SOLVED] How to stop Long numbers from auto rounding...
    By Hogrider in forum Excel General
    Replies: 5
    Last Post: 01-27-2014, 08:34 PM
  4. [SOLVED] Rounding long formula to digit above 0
    By justtune in forum Excel General
    Replies: 15
    Last Post: 09-05-2012, 08:21 PM
  5. Timing how long a number in a cell remains above a certain value?
    By emilehalpin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2012, 09:18 AM
  6. Rounding a number up in a cell
    By KoolKat in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-28-2009, 09:42 PM
  7. Replies: 5
    Last Post: 07-17-2006, 04:39 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