Make macro work with upper case and lower case

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!

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
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Use
Code:
LCase(Target.Value) = "arrived" Then
 
Upvote 0
try:

If Target.Column = 3 And UCase(Target.Value) = "ARRIVED" Then


and similarly for the "DEPARTED" line
 
Upvote 0
Cross posted https://www.excelforum.com/excel-pr...th-upper-case-and-lower-case.html#post5224360

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
I'm so sorry; once again, my error (in cross-posting) was inadvertent. Will be very careful not to do so again. Have always made all other posts only on this site, and will continue to do so in future; to be honest, I initially hadn't realized I was posting on a different site (as the two look so similar!). I was about to post the link, as I should have done initially; thank you for having done so already. Apologies again!
 
Upvote 0

Forum statistics

Threads
1,214,431
Messages
6,119,457
Members
448,898
Latest member
drewmorgan128

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