Date Format Changing when VBA opens a file

mcfclax

New Member
Joined
Aug 23, 2013
Messages
10
Hi

If I manually open a CSV file all of the dates appear in the UK format DD/MM/YYYY. When VBA opens the exact same file the way it interprets the dates is in the US format MM/DD/YYYY. So the date 09/02/2015 changes from 9th Feb to the 2nd Sep. And the 26th Feb becomes a text field.

I am using the below very basic command to open the file and even with just this code it opens incorrectly.
Code:
Workbooks.Open Filename:="H:\Account Management\Admin\Stats\1.csv"

I've checked the system short date etc in the control panel and that shows as DD/MM/YYYY so I'm stuck as to why this is happening.

Any suggestions for either how to fix it or a work around?

Thanks

Tom
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Or save the file as a .txt file to force excel to use the text import wizard on open. Play around with the date settings for your column there.
 
Upvote 0
What if you also check the local setting something like this


Thanks for this Healey21, it works perfectly. I never knew you could dictate if local or other settings are used when opening a file.

For the life of me I can't think of a situation when you'd want to specify to use non local settings though.
 
Upvote 0

Forum statistics

Threads
1,214,948
Messages
6,122,420
Members
449,083
Latest member
Ava19

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