Ah, my part numbers are gone

mrxwantobe

Board Regular
Joined
May 2, 2002
Messages
158
Hi. I have someone sending me a .csv file of part numbers. Excel has changed the cell values of some cells from a number like 09-0398 to a date. Is there a way for me to get the correct value back or is the problem from the person who created the file. I change the cell format to general and it does change from a date but it's not the actaul part number. Thanks in advance
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
i tried that but it changes it to a completely different part number. It's like a 9-1765 ends up a 40062 or something close to that. It appears it it taking a number that it thinks is a date and converting it to a date. Now, when i try to change it to text it does change it but not back to what it was.
 
Upvote 0
Change the file extension from csv to txt (or make a copy with a txt extension) and import it. Then you can choose the Text format for that column at Step 3 of the Text Import Wizard.
 
Upvote 0
so here is exactly waht is happening. the part number in Excel is a 9-1906. I format the whole column as text and save the file as a .csv. When you open the .csv the part is now a SEPT-06 and it has changed the cell format to custom. Can this be stopped?
 
Upvote 0
Yes. I saved the Excel file as a .txt file. Then I opened Excel and imported through the wizard. On the third screen I changed that column to Text and finished the import. As a .txt file it is fine but it must be saved as a .csv. If you look at the cell format it is text so you do a Save As .csv. If you now close the file and reopen the cell format is custom and displayed as a date.
 
Upvote 0
More to the story. by doing what you said it actually fixes the problem. If you look at it in a text editor it displays correctly but if you use Excel it looks wrong. At least now it's usuable. Thanks. If you would like to see the files, let me know.
 
Upvote 0
The result you want isn't possible with a csv file, unless you parse it line by line with some VBA code. With a csv file Excel bypasses the Text Import Wizard and parses the data as it sees fit. To get the control that the Text Import Wizard gives you the extension needs to be txt.

As an aside, when you save as csv the file contains exactly what you see on the screen (you can check by opening it in Notepad). It's just when you open it in Excel that you may not get what you want. So if the reason that you must save as csv is that some other application requires that format, you shouldn't have a problem.
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top