Caitlin535
New Member
- Joined
- Jan 8, 2016
- Messages
- 21
Hello! I have the following Macro (below) in a spreadsheet I use to record work times for my employees. In column C there is a dropdown in which they are supposed to choose "ARRIVED," and then a timestamp appears in both column D and P. Similar for column E - they're supposed to select "DEPARTED" from a dropdown menu and then it enters a timestamp in both column F and Q.
The trouble is, sometimes employees type "Arrived" or "Departed" instead of using the dropdowns. Because these are the correct words the dropdown error function doesn't alert, but unfortunately the Macro doesn't run. Is there a way to make the Macro not case-dependent?
Thanks!
The trouble is, sometimes employees type "Arrived" or "Departed" instead of using the dropdowns. Because these are the correct words the dropdown error function doesn't alert, but unfortunately the Macro doesn't run. Is there a way to make the Macro not case-dependent?
Thanks!
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Handler
If Target.CountLarge > 1 Then Exit Sub
If Target.Column = 3 And Target.Value = "ARRIVED" Then
Application.EnableEvents = False
Target.Offset(0, 1) = Format(Now(), "hh:mm")
Target.Offset(0, 13) = Format(Now(), "mm-dd-yyyy hh:mm")
Application.EnableEvents = True
End If
If Target.Column = 3 And Target.Value = "(Absent)" Then
Application.EnableEvents = False
Target.Offset(0, 2) = "(Absent)"
Target.Offset(0, 13) = "(Absent)"
Application.EnableEvents = True
End If
If Target.Column = 5 And Target.Value = "DEPARTED" Then
Application.EnableEvents = False
Target.Offset(0, 1) = Format(Now(), "hh:mm")
Target.Offset(0, 12) = Format(Now(), "mm-dd-yyyy hh:mm")
Application.EnableEvents = True
End If
Handler:
Application.EnableEvents = True
End Sub