View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Opening a excel file from a macro

If the file you're opening is a CSV file, then rename the file to .txt.

Then instead of using workbooks.open, you can use Workbooks.OpenText. And that
gives you the ability to specify each field (date and the correct order).

ps. When some of your data isn't really converted to a real date, that means
that much of your data that was converted to dates didn't get converted
correctly.

Look at what the source data shows and how the data was brought in. It may be a
date. But it's not the date you want.

Graeme wrote:

When using the below code I open a file with a column of dates in a
"d/mm/yyyy" format eg 1/07/2008.

When I open the file manually the dates are fine however for some unknown
reason when the file opens with the macro dates with a "d" less then 10 are
converted to a date and changes the order of the day and month eg 7/01/2008.

"d" greater than 9 are not regognised as a date and are shown as a text entry.

Does anyone know what is going on??

Workbooks.Open FILENAME:= Range("DEFAULT_FOLDER") & Range

("WORKING_DEFAULT_FILENAME")


--

Dave Peterson