C
Chuck Virtu
I am working on a project that involes reading an Excel file, picking through
it, then creating a flat CSV file. One of the the data elements I am picking
up is a 9 character string that may be numeric, or contain one or more alpha
chatacters. Excel has a nasty habit of converting long numerics to
scientific notaion. I can overcome this by converting the "general" string
to "TEXT".
However, there is one instance where I can not get the function to
work...the string is "90333E108" ( the CUSIP for USU). Regardless, the text
string is saved properly into the CSV file. When opened in a text editor, it
reads correctly.
When opened with Excel, it is in scientific notation. Changing the field to
"text" from "scientific" still displays "9.03E+112".
Any ideas how to create an csv file that Excel will open and read correctly?
You can test this by creating an Excel workbook, format all cells as TEXT
and add the following data:
90333E108 123 2
abc 90333E108 r1312sda
123 abc 90333E108
321 123 abc
231 313 123
then use the following function:
ActiveWorkbook.SaveAs Filename:="test.csv", FileFormat:=xlCSVMSDOS,
CreateBackup:=False
("xlCVS" instead of "xlCSVMSDOS") makes no difference.
Open the file "test.csv" in note pad, you have :
90333E108,123,2
abc,90333E108,r1312sda
123,abc,90333E108
321,123,abc
231,313,123
Open in Excel and you have :
9.03E+112 123 2
abc 9.03E+112 r1312sda
123 abc 9.03E+112
321 123 abc
231 313 123
Any ideas?
Chuck
it, then creating a flat CSV file. One of the the data elements I am picking
up is a 9 character string that may be numeric, or contain one or more alpha
chatacters. Excel has a nasty habit of converting long numerics to
scientific notaion. I can overcome this by converting the "general" string
to "TEXT".
However, there is one instance where I can not get the function to
work...the string is "90333E108" ( the CUSIP for USU). Regardless, the text
string is saved properly into the CSV file. When opened in a text editor, it
reads correctly.
When opened with Excel, it is in scientific notation. Changing the field to
"text" from "scientific" still displays "9.03E+112".
Any ideas how to create an csv file that Excel will open and read correctly?
You can test this by creating an Excel workbook, format all cells as TEXT
and add the following data:
90333E108 123 2
abc 90333E108 r1312sda
123 abc 90333E108
321 123 abc
231 313 123
then use the following function:
ActiveWorkbook.SaveAs Filename:="test.csv", FileFormat:=xlCSVMSDOS,
CreateBackup:=False
("xlCVS" instead of "xlCSVMSDOS") makes no difference.
Open the file "test.csv" in note pad, you have :
90333E108,123,2
abc,90333E108,r1312sda
123,abc,90333E108
321,123,abc
231,313,123
Open in Excel and you have :
9.03E+112 123 2
abc 9.03E+112 r1312sda
123 abc 9.03E+112
321 123 abc
231 313 123
Any ideas?
Chuck