Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
nbs nbs is offline
external usenet poster
 
Posts: 7
Default Date Formatting in Code

This continues from the string vs. date formatting help
provided earlier and which was helpful in determining the
fact that one is a string and one is not. Here this is the
souce of the string:

Sheets("Corrective Actions").Cells(6, 5).Value =
UserForm1.Label4

If Label4 is "12/30/04 11:55:00" how to I ensure it is
written in Cells(6, 5) as date formatted and not string
formatted.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Date Formatting in Code

Hi
try:
Sheets("Corrective Actions").Cells(6, 5).Value =
CDate(UserForm1.Label4)

--
Regards
Frank Kabel
Frankfurt, Germany

"nbs" schrieb im Newsbeitrag
...
This continues from the string vs. date formatting help
provided earlier and which was helpful in determining the
fact that one is a string and one is not. Here this is the
souce of the string:

Sheets("Corrective Actions").Cells(6, 5).Value =
UserForm1.Label4

If Label4 is "12/30/04 11:55:00" how to I ensure it is
written in Cells(6, 5) as date formatted and not string
formatted.

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Date Formatting in Code

Thanks!!! That did it!!!
-----Original Message-----
Hi
try:
Sheets("Corrective Actions").Cells(6, 5).Value =
CDate(UserForm1.Label4)

--
Regards
Frank Kabel
Frankfurt, Germany

"nbs" schrieb im

Newsbeitrag
...
This continues from the string vs. date formatting help
provided earlier and which was helpful in determining

the
fact that one is a string and one is not. Here this is

the
souce of the string:

Sheets("Corrective Actions").Cells(6, 5).Value =
UserForm1.Label4

If Label4 is "12/30/04 11:55:00" how to I ensure it is
written in Cells(6, 5) as date formatted and not string
formatted.

Thanks


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Date Formatting in Code

? cdate("12/30/04 11:55:00")
12/30/2004 11:55:00 AM


so
If isdate(Userform1.Label4) Then
Sheets("Corrective Actions").Cells(6, 5).Value = _
cDate(UserForm1.Label4)
Else
Sheets("Corrective Actions").Cells(6, 5).Clearcontents
End if

--
Regards,
Tom Ogilvy



"nbs" wrote in message
...
This continues from the string vs. date formatting help
provided earlier and which was helpful in determining the
fact that one is a string and one is not. Here this is the
souce of the string:

Sheets("Corrective Actions").Cells(6, 5).Value =
UserForm1.Label4

If Label4 is "12/30/04 11:55:00" how to I ensure it is
written in Cells(6, 5) as date formatted and not string
formatted.

Thanks



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
conditional formatting for cell date to equal today's date Sistereinstein Excel Worksheet Functions 2 September 10th 12 07:53 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Zip Code Formatting JWCrosby New Users to Excel 8 July 1st 06 11:17 AM
Convert a julian gregorian date code into a regular date Robert Excel Worksheet Functions 3 June 13th 06 07:03 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 12:03 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"