date format in excel

G

Guest

When manually opening a csv file in excel, a cell ("b2") shows the date as
'04/10/2004' (dd/mm/yyyy). When opening this file through a macro using the
following code.
"Workbooks.opnetext filenae:=wmspath$ & "csv\" & datafilename"
The date in cell ("b2") has changed format to '10/04/2004'. (mm/dd/yyyy)
Does anyone know how to stop this date switching, I have checked settings in
regional options with short date format of "dd/mm/yyyy".
Cheers Jonathan
 
F

Frank Kabel

Hi
in VBA use the format method. e.g.
fname = format(Range("B2"),"dd/mm/yyyy")
 
J

Jonathan

Hi Frank

Thanks very much for that, I know I could amend it, in
the vb script, but was looking to find the main fix
instead of having to check when writing more macro's.

Cheers
Jonathan
 

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