Re: Correcting time input by users
- From: "Rick Rothstein \(MVP - VB\)" <rick.newsNO.SPAM@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 29 May 2008 15:46:14 -0400
Also, in thinking about it, instead of this test...
If IsNumeric(Target) Then Exit Sub
maybe this one would be more robust...
If Not IsDate(Target.Value) Then Exit Sub
Rick
"Rick Rothstein (MVP - VB)" <rick.newsNO.SPAM@xxxxxxxxxxxxxxxxxx> wrote in message news:uUExANcwIHA.576@xxxxxxxxxxxxxxxxxxxxxxx
If Right(UCase(Target.Value), 2) = "AM" Then _
Target.Value = Left(Target.Value, Len(Target.Value) - 2) & " AM"
If Right(UCase(Target.Value), 2) = "PM" Then _
Target.Value = Left(Target.Value, Len(Target.Value) - 2) & " PM"
I believe you can replace the above code lines with this single line...
Target.Value = CDate(Target.Value)
and it will successfully handle 10:00p and 10:00a also. Of course, it returns the seconds as well, but the cell can be Custom Formatted to handle that; or we could just do it in code...
Target.Value = Replace(CDate(Target.Value), ":00 ", " ")
Rick
.
- Follow-Ups:
- Re: Correcting time input by users
- From: Sandy Mann
- Re: Correcting time input by users
- References:
- Re: Correcting time input by users
- From: Sandy Mann
- Re: Correcting time input by users
- From: Rick Rothstein \(MVP - VB\)
- Re: Correcting time input by users
- Prev by Date: Re: Correcting time input by users
- Next by Date: Formula on Creating Unique Value (Similar to Select Distinct)
- Previous by thread: Re: Correcting time input by users
- Next by thread: Re: Correcting time input by users
- Index(es):