PDA

View Full Version : [SOLVED] Populating csv. file with text values



Kaizer
05-24-2005, 03:20 AM
Hi guys,

I have an excel file with accounts sitting in column A and values sitting in column B. Accounts may look like: 40000, TotNetSls, and 60300.30150. With the code I take accounts that have some values and put them into an array. After, I put the values into csv file. Here I get the issue with the accounts like 60300.30150. In my csv file I get 60300.3015. As you can see last zero is missing. Do you know how to fix it and get the right account number?

Thank you in advance.

Kaizer

Bob Phillips
05-24-2005, 03:35 AM
Hi guys,

I have an excel file with accounts sitting in column A and values sitting in column B. Accounts may look like: 40000, TotNetSls, and 60300.30150. With the code I take accounts that have some values and put them into an array. After, I put the values into csv file. Here I get the issue with the accounts like 60300.30150. In my csv file I get 60300.3015. As you can see last zero is missing.

If you are getting the value from a cell that is formatted as such, use the text property


Range("A1").Text

or format it yourself


Format(myVar, "00000.0000")

Kaizer
05-24-2005, 03:50 AM
If you are getting the value from a cell that is formatted as such, use the text property


Range("A1").Text

or format it yourself


Format(myVar, "00000.0000")


Before posting my question here I changed the format of all my accounts to Text. It did not work. Besides, I have checked the value for one particular account that was sitting in my array and it looked just fine. I guess the problem happens when I populate the csv file.

mvidas
05-24-2005, 04:53 AM
Kaizer,

Are you noticing that problem once you re-open it in excel?
Look at the file in notepad, the trailing zero should be there. Excel treats every field in a csv as general when it is opened by double clicking or file/open, so it is cutting off that last zero. You can get around this using .OpenText in vba, or Data / Get External Data / Import Text File (so you can use the wizard) from within excel.

Matt

Kaizer
05-25-2005, 03:02 AM
Kaizer,

Are you noticing that problem once you re-open it in excel?
Look at the file in notepad, the trailing zero should be there. Excel treats every field in a csv as general when it is opened by double clicking or file/open, so it is cutting off that last zero. You can get around this using .OpenText in vba, or Data / Get External Data / Import Text File (so you can use the wizard) from within excel.

Matt


Thank you Matt,

The solution you suggest is quite long. I think I will solve it by putting the values into the new .xls file.:hi: