Date Formatting in Code

  • Thread starter Thread starter nbs
  • Start date Start date
N

nbs

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
 
Hi
try:
Sheets("Corrective Actions").Cells(6, 5).Value =
CDate(UserForm1.Label4)
 
? 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
 
Thanks!!! That did it!!!
-----Original Message-----
Hi
try:
Sheets("Corrective Actions").Cells(6, 5).Value =
CDate(UserForm1.Label4)

--
Regards
Frank Kabel
Frankfurt, Germany



.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top