Question

I have an excel file with some numbers followed by a dot, say:

12345.

I created a simple macro to convert and save the excel file into a .csv file.

The problem is the CSV file does not save the dot. The data comes out as 12345 and not 12345. I also tried manually adding the dot and saving the csv file, but the dot just dissappears.

Anyway to add the dot into the CSV file?

https://i.stack.imgur.com/UoboK.jpg

Was it helpful?

Solution

Add a single quote/apostrophe in front of the number (without a closing quote at the end), so that it reads it as text and does not auto-format it as number.

For example you have:

    12345.

Excel will auto-format that column as a number and drop the period unless you specify that it's a text only column.

Change it to:

    '12345.

Excel will read that value as a text column and will not save the apostrophe in a text-based CSV file.

Edit: In testing this, I found that ff you save it as "12345.", Excel changes the CSV file to """12345.""".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top