AND() , OR() functions in a macro

jts2004

Board Regular
Joined
Apr 21, 2004
Messages
156
I have this:
If [B37].Value = "Y" And [B30].Value = "DOG" And [J2].Value = "X" Then..

I need to include "X" or "x" so the user can enter a capital or lowercase "X"
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
If (UCase([B37].Value) = "Y" And UCase([B30].Value) = "DOG" And UCase([J2].Value) = "X") Then..
 
Upvote 0
At the top of your module, you could include:

Code:
Option Compare Text

which I believe will have the same result as Joe's code. However, if you choose this option, then all your other subs in this module will behave in the same way (which you may not want).

Regards

Richard
 
Upvote 0
The Ucase method will cast any string value passed to it as Uppercase. In other words:

dog will become DOG
Dog ................ DOG
doG ................ DOG

etc

Richard
 
Upvote 0
UCase() tells the compair to match any combimation of cases in the cell to a string indicated in all Capitals, as if the cell has only capitals when it does not.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,869
Members
449,054
Latest member
juliecooper255

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