Code not working with an input Captial letter

wagmanm

Board Regular
Joined
Feb 26, 2013
Messages
141
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?
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,388
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Try:
If LCase(Range("H13")) <> "s" Then
 

L. Howard

Well-known Member
Joined
Oct 16, 2012
Messages
4,514
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
 

bruderbell

Active Member
Joined
Aug 29, 2006
Messages
374
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,518
Messages
5,596,621
Members
414,082
Latest member
sasmita

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
Top