Converting Numeral to Time equivalent
Hi Mark,
Am Tue, 17 Nov 2020 02:34:11 -0800 (PST) schrieb NoodNutt:
I am trying to speed up data entry by just entering a number and have in auto-convert to time, eg 515 = 5:15 or 1415 = 14:15, reducing keystrokes will significantly speed up this process in Columns( 10 & 11 ).
I tried inserting it into my Worksheet_Change event, but it will not fire ( although it fires if I run the sub on it's own ).
try:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C9:C42,H9:H43,J9:K42")) Is Nothing _
Or Target.Count 1 Then Exit Sub
Select Case Target.Column
Case 3
If Target.Value = "YARD" Then
Target.Offset(, 7).Select
Else
Target.Offset(, 1).Select
End If
Case 8
Target.Offset(, 2).Select
Case 10, 11
If IsNumeric(Target) And Target <= 2359 Then
Select Case Len(Target)
Case 3
Target = TimeValue(Left(Target, 1) & ":" & Right(Target, 2))
Case 4
Target = TimeValue(Left(Target, 2) & ":" & Right(Target, 2))
End Select
Target.NumberFormat = "hh:mm"
End If
End Select
End Sub
Regards
Claus B.
--
Windows10
Office 2016
|