Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Date Formats

Hi I'm having trouble writing the right date format to a cell.

Currently I have tried

Worksheets("Forecast").Cells(ForecastMaxRowNo, 8).Value = Format(Date,
"Short Date")

Worksheets("Forecast").Cells(ForecastMaxRowNo, 8).Value = Format(Date,
"General Date")

Worksheets(sMonth).Cells(MonthTabMaxRowNo, 8).Value = FormatDateTime(Date,
vbShortDate)

Each time it comes out in American format and my regional setting on the
computer are all set to UK

When I put MSGBOX before it to test it seems to be OK. The Cell format seems
to be OK too.

Any help or suggestions would be appreciated.

Thanks

Steve


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Date Formats

Don't try to set the format using the Value property; rather, assign the
date to the Value property directly and then use the NumberFormat property
to set the format....

With Worksheets("Forecast").Cells(ForecastMaxRowNo, 8)
.Value = Date
.NumberFormat = "dd/mm/yyyy"
End With

Change the format pattern to whatever format you actually want.

--
Rick (MVP - Excel)


"Steve" wrote in message
...
Hi I'm having trouble writing the right date format to a cell.

Currently I have tried

Worksheets("Forecast").Cells(ForecastMaxRowNo, 8).Value = Format(Date,
"Short Date")

Worksheets("Forecast").Cells(ForecastMaxRowNo, 8).Value = Format(Date,
"General Date")

Worksheets(sMonth).Cells(MonthTabMaxRowNo, 8).Value = FormatDateTime(Date,
vbShortDate)

Each time it comes out in American format and my regional setting on the
computer are all set to UK

When I put MSGBOX before it to test it seems to be OK. The Cell format
seems
to be OK too.

Any help or suggestions would be appreciated.

Thanks

Steve



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Date Formats

Steve,

Doing it like this should make it pick up your regional setting

Worksheets("Forecast").Cells(ForecastMaxRowNo, 8) = Date

Mike

"Steve" wrote:

Hi I'm having trouble writing the right date format to a cell.

Currently I have tried

Worksheets("Forecast").Cells(ForecastMaxRowNo, 8).Value = Format(Date,
"Short Date")

Worksheets("Forecast").Cells(ForecastMaxRowNo, 8).Value = Format(Date,
"General Date")

Worksheets(sMonth).Cells(MonthTabMaxRowNo, 8).Value = FormatDateTime(Date,
vbShortDate)

Each time it comes out in American format and my regional setting on the
computer are all set to UK

When I put MSGBOX before it to test it seems to be OK. The Cell format seems
to be OK too.

Any help or suggestions would be appreciated.

Thanks

Steve


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Date Formats

Thanks Mike

Seems like I tried everything but the right answer! Really appreciate your
help.

Steve

"Steve" wrote:

Hi I'm having trouble writing the right date format to a cell.

Currently I have tried

Worksheets("Forecast").Cells(ForecastMaxRowNo, 8).Value = Format(Date,
"Short Date")

Worksheets("Forecast").Cells(ForecastMaxRowNo, 8).Value = Format(Date,
"General Date")

Worksheets(sMonth).Cells(MonthTabMaxRowNo, 8).Value = FormatDateTime(Date,
vbShortDate)

Each time it comes out in American format and my regional setting on the
computer are all set to UK

When I put MSGBOX before it to test it seems to be OK. The Cell format seems
to be OK too.

Any help or suggestions would be appreciated.

Thanks

Steve


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Different Date formats in text to be recognised as date value swiftcode Excel Programming 8 October 16th 09 08:37 AM
Cell Date and Listbox Date formats Corey[_3_] Excel Programming 5 December 12th 08 11:52 AM
Dealing with date formats on expiration date bliten_bsas Excel Programming 1 October 4th 07 08:47 PM
Date Formats Denise Excel Discussion (Misc queries) 4 April 4th 07 08:41 PM
Date formats Craig Excel Discussion (Misc queries) 2 January 10th 07 10:30 PM


All times are GMT +1. The time now is 12:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"