View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Converting Numeral to Time equivalent

Hi Mark,

Am Tue, 17 Nov 2020 03:04:17 -0800 (PST) schrieb NoodNutt:

Much appreciation for this. Alas it did not work though. I actually used something similar to this earlier in the day, which garnered the same outcome.
It's not triggering the cell change.

Even with the cells formatted as numbers, and entering say, 515, it stays as 515.

I also noticed you copied the Case section from earlier as it contained Case 3 & 4 which should have reflected Case 10 & 11. So this is what I ended up with.


Len(Target) can be 3 or 4 e.g. 515 or 1425

Try:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C3:C43,H3:H43,J3:K43")) Is Nothing _
Or Target.Count 1 Then Exit Sub

Select Case Target.Column
Case 3
If Target.Value = "YARD" Or Target.Value = "C0654" Then
Target.Offset(0, 7).Select
Else
Target.Offset(0, 1).Select
End If
Case 8
Target.Offset(0, 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))
Target.NumberFormat = "[h]:mm"
Target.Offset(0, 1).Select
Case 4
Target = TimeValue(Left(Target, 2) & ":" & Right(Target, 2))
Target.NumberFormat = "[h]:mm"
End Select
End If
End Select
End Sub


Regards
Claus B.
--
Windows10
Office 2016