Can "and" and "or" be used with If...Then statements?
Hi Robert,
Sure, any of the logical operators can be used in the expression that is
evaluated in the "If ... Then ... Else".
Nothing keeps you from writing stuff like
If a < 100 And Not (b = 5 Or b = 10) Then ...
It's perfectly all right to use logical AND an OR
expressions in an If..Then statement. If your expressions
are a bit complicted, be sure to include parentheses
around them to show VBA in what order to make the logical
decisions, e.g.,
If ((strDay="Saturday") OR (strDay="Sunday")) AND (blnSun
= True) Then ...
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.