IF AND OR Function

olympiac

Board Regular
Joined
Sep 26, 2010
Messages
158
I need a formula to give the following result

If Cell A2 is RAT
and cell B2 is "RATART" or "RAT" or "ARTRAT"then C2 value is "SHOW" otherwise is "HIDE"
If Cell A2 is ART
and cell B2 is "RATART" or "ART" or "ARTRAT"then C2 value is "SHOW" otherwise is "HIDE"

I have got something like this but I need to add some more conditions to get the above result
=IF(AND($L$3="RAT",M3="RATART"),"Show","Hide")
Can you help please?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
=IF(AND(A2="RAT",OR(B2="RATART", B2="RAT",B2="ARTRAT")),"SHOW",IF(AND(A2="ART",OR(B2="RATART",B2="ART",B2="ARTRAT")),"SHOW","HIDE"))

does this do the trick?
 
Last edited:
Upvote 0
Thank you.

I was about to use the following formula but excel does not allow to much IF

=IF(AND(L3=RAT,M3=RATART),"Show",IF(AND(L3=RAT,M3=RAT),"Show",IF(AND(L3=RAT,M3=ARTRAT),"SHOW",IF(AND(L3=ART,M3=RATART),"Show",IF(AND(L3=RAT,M3=ART),"HIDE",
IF(AND(L3=ART,M3=ART),"Show",IF(AND(L3=ART,M3=ARTRAT),"SHOW",IF(AND(L3=ART,M3=RATART),"SHOW",IF(AND(L3=ART,M3=RAT),"HIDE","Not Required")))

Cheers
 
Upvote 0
Here's a 2003 version:
Code:
=IF(OR(AND(L3="RAT",M3="RATART"),AND(L3="RAT",M3="RAT"),AND(L3="RAT",M3="ARTRAT"),AND(L3="ART",M3="RATART"),AND(L3="ART",M3="ART"),AND(L3="ART",M3="ARTRAT"),AND(L3="ART",M3="RATART")),"SHOW",IF(OR(AND(L3="RAT",M3="ART"),AND(L3="ART",M3="RAT")),"HIDE","Not Required"))
 
Upvote 0
What's wrong with this one?

=IF(AND(C518=hide,C515=HIDE),"HIDE",IF(AND(C518=hide,C515=SHOW),"HIDE",IF(AND(C518=not hide,C515=SHOW),"SHOW",IF(AND(C518=not hide,C515=HIDE),"HIDE","")
 
Upvote 0
I fixed it


=IF(AND($C$517="hide",C515="HIDE"),"HIDE",IF(AND($C$517="hide",C515="SHOW"),"HIDE",IF(AND($C$517="not hide",C515="SHOW"),"SHOW",IF(AND($C$517="not hide",C515="hide"),"HIDE"))))
 
Upvote 0
I fixed it


=IF(AND($C$517="hide",C515="HIDE"),"HIDE",IF(AND($C$517="hide",C515="SHOW"),"HIDE",IF(AND($C$517="not hide",C515="SHOW"),"SHOW",IF(AND($C$517="not hide",C515="hide"),"HIDE"))))

But it could be a lot more straightforward...

=IF(OR(AND($C$517="hide",C515="HIDE"),AND($C$517="hide",C515="SHOW"),AND($C$517="not hide",C515="hide")),"HIDE",IF(AND($C$517="not hide",C515="SHOW"),"SHOW","HIDE"))
 
Upvote 0
It looks like it could be more straightforward than that. It looks like all you are doing is seeing if the search text is contained in the other cell.

=IF(ISNUMBER(SEARCH(A2,B2)),"SHOW","HIDE")
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

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