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"
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
If (UCase([B37].Value) = "Y" And UCase([B30].Value) = "DOG" And UCase([J2].Value) = "X") Then..
 

jts2004

Board Regular
Joined
Apr 21, 2004
Messages
156
UCASE

Does UCASE mean any case. like "Dog" or "dOG" or will it only take "DOG" or "X".
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
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
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707

ADVERTISEMENT

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
 

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,436
Messages
5,572,104
Members
412,441
Latest member
kelethymos
Top