D
David Schuler
I need to create a sheet that finds the difference in military time.
User inputs start (Column B) and stop (Column C) time, and then the
total time is shown (Column D).
I can get it to work easy enough, except I'd like to have the user not
have to SHIFT + ; for every time.
So online, I found a VB script that fixes the problem.
-----------
Private Sub Worksheet_Change(ByVal Target As Range)
ThisColumn = Target.Column
If ThisColumn > 1 And ThisColumn < 4 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
-------------
However, with this code, Column D no longers totals the time. Typing
in 1234 correctly inputs 12:34, but in the formula bar it shows
12:34:00 PM!
The formula I have in Column D is:
=(C4-B4)*1440
This correctly shows the total time in minutes if I do not use the VB
script. But with the script, I get nothing shown.
Is there a better script or formula I could use to get the best of
both worlds?
~ Dave
User inputs start (Column B) and stop (Column C) time, and then the
total time is shown (Column D).
I can get it to work easy enough, except I'd like to have the user not
have to SHIFT + ; for every time.
So online, I found a VB script that fixes the problem.
-----------
Private Sub Worksheet_Change(ByVal Target As Range)
ThisColumn = Target.Column
If ThisColumn > 1 And ThisColumn < 4 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
-------------
However, with this code, Column D no longers totals the time. Typing
in 1234 correctly inputs 12:34, but in the formula bar it shows
12:34:00 PM!
The formula I have in Column D is:
=(C4-B4)*1440
This correctly shows the total time in minutes if I do not use the VB
script. But with the script, I get nothing shown.
Is there a better script or formula I could use to get the best of
both worlds?
~ Dave