Best way to get multiple OR conditions

Eisasuarez

Well-known Member
Joined
Mar 23, 2012
Messages
653
Hi All

i have a list of OR conditions that need to be met before returning a value

ie =if(or(a1=“test1”,a1=“test2”,a1=“test3”)...etc

rather than having to change the values inside the cell if the or conditions was to grow, how can I look it up in a range

ie =if(or(a1=OrConditionCriterias),”yes”,”no”)
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
One of many ways:


Excel 2010
ABC
1test4test1
2TRUEtest2
3test3
4test4
5test5
6test6
Sheet3
Cell Formulas
RangeFormula
A2=COUNTIF($C$1:$C$6,A1)>0
 
Upvote 0
An alternative way to do this is to set an dymanic name range called (Or_Conditions) in the below example in column D

To create the dynamic name range click on Formula Tab > Name Manager > New > Name enter : Or_Conditions > Refers to enter : =OFFSET(Sheet1!$D$1,0,0,COUNTA(Sheet1!$D:$D),1)

Then in column B you'll have your array formula {=IF(SUM(--(A2=Or_Conditions))>0,"Yes","No")}


Book1
ABCD
1List to validateif formulaOr Conditions
2test2Yestest1
3AppleNotest2
4test1Yestest3
5test3Yes
6test1Yes
Sheet1
Cell Formulas
RangeFormula
B2{=IF(SUM(--(A2=Or_Conditions))>0,"Yes","No")}
Press CTRL+SHIFT+ENTER to enter array formulas.
Named Ranges
NameRefers ToCells
Or_Conditions=OFFSET(Sheet1!$D$1,0,0,COUNTA(Sheet1!$D:$D),1)
 
Upvote 0
You can also aviod the array formula by applying sheetspread solution

=IF(COUNTIF(Or_Conditions,A2)>0,"Yes","No")
 
Upvote 0
Hi,

Why not Just use COUNTIF as sheetspread suggested? That's what I'd do.


Book1
ABCD
1List to validateif formulaOr Conditions
2test2Yestest1
3AppleNotest2
4test1Yestest3
5test3Yes
6test1Yes
Sheet141
Cell Formulas
RangeFormula
B2=IF(COUNTIF(D$2:D$100,A2),"Yes","No")


As the OR conditions grow, add to D Column, B2 formula copied down, change adjust cell reference/range as needed.
 
Upvote 0
To make a Dynamic Named Range I always use a Table

Create a Table name it MyDate

Now every time you add more data to your Table the Named Range expands
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,264
Members
449,075
Latest member
staticfluids

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