ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple IF conditions-AND/OR (https://www.excelbanter.com/excel-programming/438446-multiple-if-conditions.html)

richzip

Multiple IF conditions-AND/OR
 
Hello,

I have the following If/Then statement set up.

If (Cond1) and (Cond2) and (Cond3a) or (Cond3b) or (Cond3c) Then

I want the "then" to be fulfilled only if BOTH Conditions 1 AND 2, as well
as "at least one" of the # 3 conditions are true. How would I properly use
and/or combinations as well as parenthese/brackets?

I thought it might be something like this, but it didn't work:

If (Cond1) and (Cond2) and [(Cond 3a) or (Cond3b) or (Cond3c)] Then


Jacob Skaria

Multiple IF conditions-AND/OR
 
Try

a = 1
b = 2
c = 5

If a = 1 And b = 2 And (c = 3 Or c = 4 Or c = 5) Then
MsgBox "Success"
End If

--
Jacob


"richzip" wrote:

Hello,

I have the following If/Then statement set up.

If (Cond1) and (Cond2) and (Cond3a) or (Cond3b) or (Cond3c) Then

I want the "then" to be fulfilled only if BOTH Conditions 1 AND 2, as well
as "at least one" of the # 3 conditions are true. How would I properly use
and/or combinations as well as parenthese/brackets?

I thought it might be something like this, but it didn't work:

If (Cond1) and (Cond2) and [(Cond 3a) or (Cond3b) or (Cond3c)] Then


stevefromnaki

Multiple IF conditions-AND/OR
 
Try nested if statements:

If (Cond1) and (Cond2) Then
If (Cond3a) or (Cond3b) or (Cond3c) Then
...your code here
EndIf
EndIf

Hope that helps :)

"richzip" wrote:

Hello,

I have the following If/Then statement set up.

If (Cond1) and (Cond2) and (Cond3a) or (Cond3b) or (Cond3c) Then

I want the "then" to be fulfilled only if BOTH Conditions 1 AND 2, as well
as "at least one" of the # 3 conditions are true. How would I properly use
and/or combinations as well as parenthese/brackets?

I thought it might be something like this, but it didn't work:

If (Cond1) and (Cond2) and [(Cond 3a) or (Cond3b) or (Cond3c)] Then



All times are GMT +1. The time now is 10:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com