Opening CSV files causes Date Differences

M

Mark

Currently we have a CSV within the file we have a date of
5th August displayed as "05/08" within the CSV file.
When we open it from excel it shows 5-AUG. But if we open
it from code it shows 8-MAY. Any ideas of how to open the
file in VBA code to show the correct date of 5-AUG

Thanks in Advance

Mark
 
D

Dave Peterson

VBA is very USA centric--especially with .csv files.

I think I'd rename the file to .txt and then record a macro when I opened it
once. Then make sure you choose the correct date format for each field.

Then use that macro to open subsequent files with one minor change to the
macro. I'd pause and let the user select what file is coming in:

Maybe you can use:

dim myFilename as variant
myfilename = application.getopenfilename("Text files, *.txt")
if myfilename = false then
exit sub 'user hit cancel
end if

Workbooks.OpenText Filename:=myfilename, ....rest of your code....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top