Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel opening CSV files via Macro wrong 1

Status
Not open for further replies.

TheLad

Technical User
Aug 3, 2001
3,846
GB
Guys

I am opening a CSV file from an Excel macro and the format of the date (stored in column A) keeps getting messed up. Column A has the date in as per the contents of the CSV file but from Row 13 onwards, the format of the cell changes from Date to General.

Now if I open the CSV file normally in Excel (File / Open etc...), the CSV file opens perfectly, the contents of Column A are all formatted to Date, and I do not have any of the date formatting issues.

I recorded the process and pasted that into my Macro but it still shows the symptoms described above when opened as part of the Macro code. There is nothing in the CSV file that would cause this behaviour

Does anyone have any ideas please?

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
Any chance you could post some relevant info like, say, your actual code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi,

"the format of the cell changes from Date to General."

A .csv file has NO FORMAT. It is merely a TEXT file.

Rather than using Workbooks.Open..., use Data > Import External Data > IMPORT and in the Import Wizard, you can explicity specify how you want your file parsed. Once you get it to work, use your macro recorder.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks SkipVought for your (non sarcastic sounding) answer, that is exactly what I needed :)

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
TheLad,

Let me know if you need any help with this further. I have made some macros to handle .csv files importation.
 
Thanks for the offer, I think I am ok for now as the CSV file is now importing ok and I can manipulate it as I like.

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top