Time Entry Issue

Fireman1224

New Member
Joined
Oct 20, 2008
Messages
42
Tried to follow the instructions:

http://www.youtube.com/user/bjele123#p/c/76C979CEFD1A4B30/42/FVTB6ruazJU

but I can't get the proper time to display..it works for times >10:00, but 00:00 to 09:59 is weird. Here is the code I used in Excel 2007

Private Sub Worksheet_Change(ByVal Target As Range)
If IsEmpty(Target) Then
Exit Sub

ElseIf Target.Column = 16 Then
Application.EnableEvents = False
Target.Value = Left(Target.Value, 2) & ":" & Right(Target.Value, 2)
Application.EnableEvents = True
End If
End Sub

I also want to replace Target.Column =16 to all cells within a named range "Time".

Please Help!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
The code below will answer your 2nd request. What is it that is weird about times < 10:00?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If IsEmpty(Target) Then
        Exit Sub
    ElseIf Not Intersect(Target, Range("Time")) Is Nothing Then
        Application.EnableEvents = False
        Target.Value = Left(Target.Value, 2) & ":" & Right(Target.Value, 2)
        Application.EnableEvents = True
    End If
End Sub
 
Upvote 0
Thanks for the range fix, here's what I get with <1000 entry...

0700 = 1/2/1900 10:00:00 PM
0100 = 10:00:00 AM
0300 = 1/1/1900 6:00:00 AM

I don't understand the pattern...
 
Upvote 0
Yes. All cells in the range "Time" have the formatting foe hh:mm.

0030 = 00:30
0100 = 01:00
1000 = 10:00
etc...

Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,076
Members
449,094
Latest member
mystic19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top