ok...I have some vba code that im using toi convert a numeric strinf to a time..but I want to also enter a 4 digit month so that it auto formats...ie (0112 2311) = 1/12 23:11
here is what I got so far
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
'Define the range where you want the code to work (our example is "C:G").
'Change within the " marks
If Intersect(Target, Range("C:G")) Is Nothing Then Exit Sub
On Error GoTo errHandler:
With Target
If IsNumeric(.Value) Then
Application.EnableEvents = False
Select Case .Value
Case 0
.NumberFormat = "hh:mm"
Case 1 To 99
.Value = TimeSerial(0, .Value, 0)
.NumberFormat = "hh:mm"
Case 100 To 2399
.Value = TimeSerial(Int(.Value / 100), .Value Mod 100, 0)
.NumberFormat = "hh:mm"
End Select
End If
End With
errHandler:
Application.EnableEvents = True
End Sub
Bookmarks