LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Strange? VBA code returns wrong date format (not a date)

The following code returns a value that looks like a date/time, but is not a
date/time. Eksample: The code returns a cell value 28.09.2007 13:58 (as seen
in the formula field). Normally a date formated as "dd.mm.yyyy hh:mm" will
return a value in the formula field like this: 28.09.2007 13:58:00, and it
shows up as 28.09.2007 13:58 in the cell. I noticed that the code returns a
value with one space between the date and the time. A properly formated date
manually typed in has two spaces. When I manually change to two spaces
between the time and the date in the value placed by the code it
automatically changes from 28.09.2007 13:58 to 28.09.2007 13:58:00 in the
formula field. The apperance in the cell is unchanged. The reason I
discovered this was that I am checking for the largest value in two nearby
cells =IF(L21K21;"Overdue";"") and it returned an unlogic responce.

Whats wrong with this code?

Private Sub CommandButton2_Click()
.Value = Now
.NumberFormat = "dd.mm.yyyy hh:mm"
ActiveCell.Value = Format(Now(), "dd.mm.yyyy hh:mm")
End Sub
--
Thanks
 
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
Workday function returns the wrong date when the duration is 5 day KarenMA Excel Worksheet Functions 5 October 25th 09 07:48 PM
date in wrong format Mike New Users to Excel 3 November 15th 08 08:42 PM
Date in wrong format GKW in GA Excel Discussion (Misc queries) 6 February 19th 08 03:21 PM
code to convert date from TEXT format (03-02) to DATE format (200203) Gauthier[_2_] Excel Programming 0 September 22nd 04 03:26 PM
code pasting a date changes date format in current month only Edward[_5_] Excel Programming 0 May 10th 04 06:13 PM


All times are GMT +1. The time now is 09:46 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"