ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   opening worksheet (https://www.excelbanter.com/excel-programming/401423-opening-worksheet.html)

RobcPettit[_2_]

opening worksheet
 
Hi, I have a worksheet that contains a column of dates. If I double
click to open, or use File-Open etc, the dates format ok. I want to
open using vba, so I recorded a macro, but when I run the macro, some
dates format ok, august dates, others format as usa, september dates.
then code I used is Workbooks.Open Filename:= _
"C:\Documents and Settings\Robert\Desktop\FOOTBALL\Soccer
Predictions\E0.csv". Any ideas please.
Regards Robert

RobcPettit[_2_]

opening worksheet
 
Forgot to say, the file is in csv format.

joel

opening worksheet
 
Usually problems like this are attributed to different type an d amount of
white spaces (spaces, tabs, other non-printable characters). You may need to
add to your macro some additionals code such as trim or substitue tabs for
nothing.

"RobcPettit" wrote:

Hi, I have a worksheet that contains a column of dates. If I double
click to open, or use File-Open etc, the dates format ok. I want to
open using vba, so I recorded a macro, but when I run the macro, some
dates format ok, august dates, others format as usa, september dates.
then code I used is Workbooks.Open Filename:= _
"C:\Documents and Settings\Robert\Desktop\FOOTBALL\Soccer
Predictions\E0.csv". Any ideas please.
Regards Robert


Dave Peterson

opening worksheet
 
In xl2003+ (maybe xl2002???), there's a "local:=true" parm that you can pass to
the workbooks.open line. It'll use the regional settings (under control panel)
for the date format.

If you don't have that parm in your version of excel, then maybe you could
rename the file from *.csv to *.txt. Then you can specify what each field
should be--including the date order (mdy or dmy or...).



RobcPettit wrote:

Hi, I have a worksheet that contains a column of dates. If I double
click to open, or use File-Open etc, the dates format ok. I want to
open using vba, so I recorded a macro, but when I run the macro, some
dates format ok, august dates, others format as usa, september dates.
then code I used is Workbooks.Open Filename:= _
"C:\Documents and Settings\Robert\Desktop\FOOTBALL\Soccer
Predictions\E0.csv". Any ideas please.
Regards Robert


--

Dave Peterson

RobcPettit[_2_]

opening worksheet
 
Thankyou both for your replys. I used the "local:=true" parm. Worked a
treat. It always amazes me as to how simple the solution can be.
Thanks for pointing it out.
Regards Robert

On 20 Nov, 16:58, Dave Peterson wrote:
In xl2003+ (maybe xl2002???), there's a "local:=true" parm that you can pass to
the workbooks.open line. It'll use the regional settings (under control panel)
for the date format.

If you don't have that parm in your version of excel, then maybe you could
rename the file from *.csv to *.txt. Then you can specify what each field
should be--including the date order (mdy or dmy or...).

RobcPettit wrote:

Hi, I have a worksheet that contains a column of dates. If I double
click to open, or use File-Open etc, the dates format ok. I want to
open using vba, so I recorded a macro, but when I run the macro, some
dates format ok, august dates, others format as usa, september dates.
then code I used is Workbooks.Open Filename:= _
"C:\Documents and Settings\Robert\Desktop\FOOTBALL\Soccer
Predictions\E0.csv". Any ideas please.
Regards Robert


--

Dave Peterson




All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com