Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
twig
 
Posts: n/a
Default Problem with Date format from VBA code

I have written some VBA code to make a spreadsheet operate as a cash till.
I use the Now method to populate a cell for the till receipt date , and
cells in the Date column for a sales records worksheet. I format these cells
to be dd/mm/yyyy, as follows:
'--- use a cell to store todays date value
Range("CF.Date").Value = Now
<skip some lines
'--- post formatted date to sales record
c.Offset(1, 1).Value = Format(Range("CF.Date").Value, "dd/mm/yy")

Here's the problem:
The code works fine for every date after the twelfth of the month... but for
the first twelve days of each month the date appears in the cell in a
mm/dd/yy format.

Any ideas?

  #2   Report Post  
Frank Kabel
 
Posts: n/a
Default

Hi
use
c.Offset(1, 1).Value =Range("CF.Date").Value

and use the numberformat property for your format

--
Regards
Frank Kabel
Frankfurt, Germany

"twig" schrieb im Newsbeitrag
...
I have written some VBA code to make a spreadsheet operate as a cash

till.
I use the Now method to populate a cell for the till receipt date ,

and
cells in the Date column for a sales records worksheet. I format

these cells
to be dd/mm/yyyy, as follows:
'--- use a cell to store todays date value
Range("CF.Date").Value = Now
<skip some lines
'--- post formatted date to sales record
c.Offset(1, 1).Value = Format(Range("CF.Date").Value, "dd/mm/yy")

Here's the problem:
The code works fine for every date after the twelfth of the month...

but for
the first twelve days of each month the date appears in the cell in a
mm/dd/yy format.

Any ideas?


  #3   Report Post  
Ken Macksey
 
Posts: n/a
Default

Hi

You could also make sure that in the control panel, regional and language
options that the short date is set correctly for what you want.(win xp, May
be found under time and date settings or elsewhere in win 98.)

HTH

Ken


  #4   Report Post  
twig
 
Posts: n/a
Default

Thanks Frank, that cured it



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
Problem with date base units for x axis Peter Carr Charts and Charting in Excel 1 December 15th 04 10:11 AM
Problem Code: Retrieving Stored Access 03 Query Bettergains Excel Discussion (Misc queries) 2 December 7th 04 05:11 PM
cut and paste format problem Francis Hayes (The Excel Addict) Excel Discussion (Misc queries) 1 December 7th 04 03:23 PM
Date on two lines using a custom cell format possible? .:mmac:. Excel Discussion (Misc queries) 5 December 4th 04 10:41 PM
How can I format a cell so date field only displays the Month? tk_2u Excel Discussion (Misc queries) 3 December 4th 04 01:54 AM


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

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

About Us

"It's about Microsoft Excel"