
RMarco,
Fechou! Muito bom! Vai ajudar muita gente.
Vou colocar aqui seu código para o pessoal do forum:
Código: Selecionar todos
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Função para entrar Horas sem digitar os ":"
'Por: José Luiz Martins
Dim TimeStr As String
On Error GoTo EndMacro
If Application.Intersect(Target, Range("C5:C25,D5:D25,E5:E25,H5:H25,I5:i25")) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
If IsNull(Target.Value) Then Exit Sub
Application.EnableEvents = False
With Target
If .HasFormula = False Then
Select Case Len(.Formula)
Case 1 To 2 ' ex: 12 = 12:00:00
TimeStr = "00:00" & ":" & .Formula
Case 3 ' ex:, 735 = 00:07:35
TimeStr = "00:0" & Left(.Formula, 1) & ":" & Right(.Formula, 2)
Case 4 ' ex:, 1234 = 12:34
TimeStr = "00:" & Left(.Formula, 2) & ":" & Right(.Formula, 2)
Case 5 ' ex:, 12345 = 1:23:45 e não 12:03:45
TimeStr = Left(.Formula, 1) & ":" & _
Mid(.Formula, 2, 2) & ":" & Right(.Formula, 2)
Case 6 ' ex:, 123456 = 12:34:56
TimeStr = Left(.Formula, 2) & ":" & _
Mid(.Formula, 3, 2) & ":" & Right(.Formula, 2)
Case Else
Err.Raise 0
End Select
.Formula = Format(TimeValue(TimeStr), "hh:mm:ss")
End If
End With
Application.EnableEvents = True
Exit Sub
EndMacro:
MsgBox "Você não entrou com uma Hora válida."
Range(Target.Address).Select
Selection.ClearContents
Application.EnableEvents = True
End Sub
Valeu!