+ Reply to Thread
Results 1 to 7 of 7

Exporting paramater values to excel retaining precision of number

  1. #1
    Registered User
    Join Date
    12-29-2011
    Location
    Gaithersburg, MD
    MS-Off Ver
    Excel 2003
    Posts
    12

    Exporting paramater values to excel retaining precision of number

    Routinely I export parameter values from a data analysis program in columns to EXCEL : the number of decimal points needed varies from parameter to parameter. I have tried a CSV file format. I find that then if I have a parameter with a value, e.g. 13.46 then after export into Excel it is 13.46. But for the same parameter if I have a value of 13.00 then in Excel it is 13. Similarly for a different parameter if it is reported as required in my data analysis program as e.g. 0.1235 then it shows 0.1235 in Excel. On he other hand if the parameter is 0.1200 in my data analysis program then in Excel it is shown as 0.12. I am wondering if this can be addressed in Excel so that the same numbers are reported in Excel as the source data analysis program.


    Angus

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Exporting paramater values to excel retaining precision of number

    Excel always thinks it's being helpful stripping off these zero values, Ugh.

    In Excel, the only way to get the trailing or leading zeros to be left in tact is to format that data as text. Sorry.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Exporting paramater values to excel retaining precision of number

    Hi angusmdmclean,

    Excel stores your number exactly as it is imported up to about 15 decimal places. Please note that the numbers are stored in binary format, so some fractional numbers may not be stored as you see the number. A hypothetical example would have 0.1 stored as 0.09999999999999999.

    Excel displays the number according to the format of each cell. You can control what is displayed, by adusting this format to a certain number of decimal places for each cell or for a range of cells.

    I hope this helps.

    Lewis

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,874

    Re: Exporting paramater values to excel retaining precision of number

    Storing as text may be one solution, or it may cause other problems.

    Question: for the purposes of your analysis, what is the difference between 13 and 13.00 and 13.0000 and 13.000000000000000? Numerically, these four values are all really the same value. Same as 0.12=0000.120000=0.12000=0.12000000=1.2E-1.

    IMO, before devising a solution, we need you to explain the "significance" of these insignificant 0's.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Registered User
    Join Date
    12-29-2011
    Location
    Gaithersburg, MD
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Exporting paramater values to excel retaining precision of number

    Mr Shorty: Thank you for your comments. I am in the pharmaceutical industry. The purpose of maintaining the precision to 13.00 in Excel is that the stripping to 13 is raising question from quality assurance regarding the integrity of the data. Additionally it is very labor intensive for me to put the 0 back in again in the cells. I have different parameters in different columns and sometimes I require 1 decimal or it could be 4. So I have a lot of manual reformatting to do and it is also labor-intensive. Any thoughts,

    Angus

  6. #6
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Exporting paramater values to excel retaining precision of number

    Quote Originally Posted by angusmdmclean View Post
    The purpose of maintaining the precision to 13.00 in Excel is that the stripping to 13 is raising question from quality assurance regarding the integrity of the data. Additionally it is very labor intensive for me to put the 0 back in again in the cells. I have different parameters in different columns and sometimes I require 1 decimal or it could be 4. So I have a lot of manual reformatting to do and it is also labor-intensive.
    Unfortunately, you're SOL unless you want to resort to using VBA either to import the data or to format the data after importing it.

    When opening or importing a CSV (or ".txt") file, Excel always formats cells as General, with some exceptions for special numeric forms that Excel recognizes, such as dates, times and percentages.

    The General format determines how many decimal places to display based on the value and the column width. In particular, it never displays trailing fractional zeros.

    Without your providing some data to demonstrate the file structure, it is not feasible for us to implement a VBA procedure to import or reformat the data.

    If you want to go in that direction, it would be best if you upload an example CSV file (not the Excel file) to file-sharing website, and post the pubic/share URL here.

    [ERRATA] I forgot that this forum allows us to attach files; and the moderators prefer that. Click on Go Advanced to find the Attach icon.

    Alternatively, you might simply describe the file structure, if it is simple enough to describe.

    I would suggest that the VBA import the data from the CSV file, instead of trying to reformat the data after Excel reads or imports the CSV file. Based on your description, I suspect that the VBA code needs to see the original form of the data in the text file in order to infer the correct cell format to use.
    Last edited by joeu2004; 11-15-2015 at 03:41 PM. Reason: errata

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,874

    Re: Exporting paramater values to excel retaining precision of number

    Is the end goal to consistently show 4 significant digits (13.00, 0.1200, 1.450, 240.0)? In the pharmaceutical industry, are your readers familiar enough with scientific notation to be able to read 1.300E1, 1.200E-1, 1.450E0, 2.400E+2? Formatting the destination cells as 0.000E+0 will consistently show four significant digits in scientific notation.

+ 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] Make cell display double-precision number
    By Test123Test in forum Excel General
    Replies: 1
    Last Post: 04-26-2013, 02:13 PM
  2. Retaining formula result when exporting WS to Text files
    By troth in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2011, 05:35 AM
  3. Replies: 1
    Last Post: 07-01-2009, 09:14 AM
  4. Macro exporting data from a spreadsheet to word and retaining it as a table
    By ggabs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-09-2009, 05:53 AM
  5. Replies: 0
    Last Post: 08-15-2006, 06:52 PM
  6. [SOLVED] Number precision
    By Jake in forum Excel General
    Replies: 2
    Last Post: 05-05-2006, 06:30 PM
  7. Changing number precision of a trendline equation
    By Harsh_Shah in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-21-2005, 10:05 PM
  8. Precision displayed does not match precision in cell
    By James Wilkerson in forum Excel General
    Replies: 10
    Last Post: 06-15-2005, 10: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