MariannMcCarthy
New Member
- Joined
- Jan 10, 2013
- Messages
- 3
I need serious help - I am trying to set up a spreadsheet so that when a user enters the time from an employees time sheet they can 10-key it in without having to enter the colon or AM / PM. I have this code below - when I enter "130" in cell I get 01:30 AM - can I get this to default to PM ? the only am times that will be used are from 6:00 AM - 11:59 AM.
Private Sub Worksheet_Change(ByVal Target As Range)
'Declare 'Start time Range
Dim rStartime As Range
' Set Start Time Column
Set rStartime = Me.Range("A1:A10")
If Not Intersect(Target, rStartime) Is Nothing Then
Application.EnableEvents = False
Target.Value = TimeSerial(Left$(Target.Value2, Len(Target.Value2) - 2), Right$(Target.Value2, 2), 0)
Application.EnableEvents = True
End If
Private Sub Worksheet_Change(ByVal Target As Range)
'Declare 'Start time Range
Dim rStartime As Range
' Set Start Time Column
Set rStartime = Me.Range("A1:A10")
If Not Intersect(Target, rStartime) Is Nothing Then
Application.EnableEvents = False
Target.Value = TimeSerial(Left$(Target.Value2, Len(Target.Value2) - 2), Right$(Target.Value2, 2), 0)
Application.EnableEvents = True
End If