+ Reply to Thread
Results 1 to 5 of 5

Copy cell as non-scientific number VBA

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Copy cell as non-scientific number VBA

    I am copying a cell from another workbook using VBA. It is importing the number with scientific notation. I want to copy the cell without the scientific notation. I have tried to format the cells in the destination worksheet prior to import and other methods but having no luck. The line I am using to copy is: (I have attached a sample spreadsheet if needed; I can't upload the data file as it is in a .csv format)
    Please Login or Register  to view this content.
    The entire code is:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by maacmaac; 02-07-2012 at 09:53 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Copy cell as non-scientific number VBA

    Format the cells of interest as text beforehand (or in your code).
    Entia non sunt multiplicanda sine necessitate

  3. #3
    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,425

    Re: Copy cell as non-scientific number VBA

    In cell F4 you have 2320000000000000000 which is displayed as 2.32E+18

    The reason for that is the size of that number ... all those zeroes. Excel can only cope with 15 significant digits and here you have 20, hence the scientific notation.

    You might get away with:

    Please Login or Register  to view this content.

    To test:

    Please Login or Register  to view this content.

    Note that if I don't put the 2320000000000000000 in quotes, VBA converts it to scientific notation.


    Regards, TMS
    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


  4. #4
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Re: Copy cell as non-scientific number VBA

    I tried following, which works
    Please Login or Register  to view this content.
    I also tried following, which did not work
    Please Login or Register  to view this content.
    I also tried to format the cells of interest first as text. That didn't work either. I have attached a copy of the source data (I converted from .csv to .xls in order to attach). The problem column is "AR". Thanks for the comments.
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Re: Copy cell as non-scientific number VBA

    I was finally able to figure out a workaround. I had to format the source file first as suggested by SHG. It probably isn't the most efficient code, but it solves what I am trying to do. Thanks for all the comments.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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