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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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