Mega Code Archive

 
Categories / VisualBasic Script / Excel
 

Use a Change event to take what is in the cell and insert the colon for you

Private Sub Worksheet_Change(ByVal Target As Range)     Dim ThisColumn As Integer     Dim UserInput As String, NewInput As String     ThisColumn = Target.Column     If ThisColumn < 3 Then         UserInput = Target.Value         If UserInput > 1 Then             NewInput = Left(UserInput, Len(UserInput) - 2) & ":" & _             Right(UserInput, 2)             Application.EnableEvents = False             Target = NewInput             Application.EnableEvents = True         End If     End If End Sub