ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date Formatting in Code (https://www.excelbanter.com/excel-programming/312550-date-formatting-code.html)

nbs

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

Frank Kabel

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



Tom Ogilvy

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




No Name

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


.



All times are GMT +1. The time now is 05:48 PM.

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