• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Changes Date Format of CSV File

HODY

New Member
Hi all

Having used this site for many years and found it really useful, I am now in need of some more assistance please!

We download a .csv file save it on my C:\ which then needs to be opened and formatted.

I have written a very basic macro to open the file called sgh1.csv.
Code is:
ChDir "C:\"
Workbooks.Open Filename:="C:\sgh1.csv"

The query;
When I open sgh1.csv file normally, via Excel/start it opens up with no problems. All as it should. Date formatting in column F dd/mm/yyyy. (see the first section in green of the attached file)

However... when I run my macro which opens the file, the dates in column F, where possible turn to mm/dd/yyyy ? (see the second section in orange of the attached file)

I can't understand this at all.

Can anybody assist please.

many thanks.
 

Attachments

  • chan 1.xls
    51.5 KB · Views: 8
Sorry Marc

This is the code:
[ChDir "C:\"
Workbooks.Open Filename:="C:\sgh1.csv"]

And I've attached two files, sghok.txt that is correct and sghwrong.txt that has been opened via the macro which is wrong.

Thanks.
 

Attachments

  • sghok.txt
    13.3 KB · Views: 1
  • sghwrong.txt
    13.3 KB · Views: 1
Working on my side like this :​
Code:
    Workbooks.Open "D:\Tests4Noobs\sghok.txt", Local:=True
Do you like it ? So thanks to click on bottom right Like !
 
Back
Top