Code not working with an input Captial letter

wagmanm

Board Regular
Joined
Feb 26, 2013
Messages
144
I have code that I just noticed will not work if user inputs a capital S. I have tried a few things but I can not seem to get it to work.
Here was the original code:
If Range("H13") <> "s" Then

I tired this:
If Range("H13") <> "s" or "S" Then

I'm sure there must be an easy way to do this can anyone help me?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try:
If LCase(Range("H13")) <> "s" Then
 
Upvote 0
One way is to place this statement Option Compare Text at the very top of the module the code is in, right below or above Option Explicit if you are using that also.


Regards,
Howard
 
Upvote 0
The syntax for OR requires that use a full expression on each side of the OR. So you might have tried

<code>If Range("H13") = "s" Or Range("H13") = "S" Then
else
'here is your code
end if</code>

But that isn't as clean as what's already been proposed. Just saying, you weren't necessarily on a dead end trying to use OR
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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