ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MS Excel If statement containing AND within an OR (https://www.excelbanter.com/excel-programming/407823-ms-excel-if-statement-containing-within.html)

prog

MS Excel If statement containing AND within an OR
 
Hi,

I have a quick question on how to add a AND statement within an OR. Like
the below:

if(OR(x=1, y=2, b=3,( j=5 AND t=9 AND p=4))

Tom Hutchins

MS Excel If statement containing AND within an OR
 
From your use of variables in the statement, it looks like you are asking
about combining OR with AND in an IF statement in VBA. That could be done
like this:

If (x = 1) Or (y = 2) Or (b = 3) Or (j = 5 And t = 9 And p = 4) Then

If you mean how to combine OR with AND in a worksheet IF function, that
could be done like this (I have replaced the variables with cell references):

=IF(OR(H1=1,H2=2,H3=3,AND( J1=5,J2=9,J3=4)),TRUE,FALSE)

Hope this helps,

Hutch

"prog" wrote:

Hi,

I have a quick question on how to add a AND statement within an OR. Like
the below:

if(OR(x=1, y=2, b=3,( j=5 AND t=9 AND p=4))



All times are GMT +1. The time now is 12:06 PM.

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