Thread: Time Format
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 390
Default Time Format

Thanks to you and Stef for your great help in time.

"Jacob Skaria" wrote:

That should be in one line..Try copy pasting the below code....

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:A10")) Is Nothing Then
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target = Left(Format(Target.Value, "0000"), 2) & ":" & _
Right(Format(Target.Value, "0000"), 2)
Application.EnableEvents = True
End If
End If
End Sub


--
Jacob


"MAX" wrote:

An error is given and to help you these 2 lines appear in RED.
Target = Left(Format(Target.Value, "0000"), 2) & ":" &
Right(Format(Target.Value, "0000"), 2)

"Jacob Skaria" wrote:

Try the below..Modify the range to suit your requirement

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:A10")) Is Nothing Then
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target = Left(Format(Target.Value, "0000"), 2) & ":" &
Right(Format(Target.Value, "0000"), 2)
Application.EnableEvents = True
End If
End If
End Sub

--
Jacob


"MAX" wrote:

Hello

I have a worksheet where one of the columns is TIME. All I want is that I
write 0315 (3.15 AM) and it appears as 03:15. Is there a solution for this?

Thanks in advance.