ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Embedding an OR statement in an IF statement efficiently (https://www.excelbanter.com/excel-discussion-misc-queries/218754-embedding-statement-if-statement-efficiently.html)

Chatnoir11

Embedding an OR statement in an IF statement efficiently
 
Hi. I am doing a simple IF statement with an OR in it.

If(OR(B2="A",B2="B",B2="C"), "X","Y") but I have many more of the OR
criteria, so it takes a long time to type, lots of room for typos.

Is there a more efficient way where I can say, basically if B2 equals
anything in this list, then "X", otherwise "Y"? I tried a dozen variations
but kept getting the "VALUE" error.

Thanks! I do these a lot, so I'd like to speed it up...


Gary''s Student

Embedding an OR statement in an IF statement efficiently
 
Say you one hundred possible valid values for the IF. Rather than make a
super-long formula; list them in a column, say column Z from Z1 thru Z100.
And then:

=IF(COUNTIF(Z1:Z100,B2)0,"X","Y")

--
Gary''s Student - gsnu200830


"Chatnoir11" wrote:

Hi. I am doing a simple IF statement with an OR in it.

If(OR(B2="A",B2="B",B2="C"), "X","Y") but I have many more of the OR
criteria, so it takes a long time to type, lots of room for typos.

Is there a more efficient way where I can say, basically if B2 equals
anything in this list, then "X", otherwise "Y"? I tried a dozen variations
but kept getting the "VALUE" error.

Thanks! I do these a lot, so I'd like to speed it up...


Dave Peterson

Embedding an OR statement in an IF statement efficiently
 
=IF(OR(B2={"A","B","C"}),"X","Y")


Chatnoir11 wrote:

Hi. I am doing a simple IF statement with an OR in it.

If(OR(B2="A",B2="B",B2="C"), "X","Y") but I have many more of the OR
criteria, so it takes a long time to type, lots of room for typos.

Is there a more efficient way where I can say, basically if B2 equals
anything in this list, then "X", otherwise "Y"? I tried a dozen variations
but kept getting the "VALUE" error.

Thanks! I do these a lot, so I'd like to speed it up...


--

Dave Peterson

Chatnoir11

Embedding an OR statement in an IF statement efficiently
 
D'oh! So simple I never considered that! THANK YOU SO MUCH!!

"Gary''s Student" wrote:

Say you one hundred possible valid values for the IF. Rather than make a
super-long formula; list them in a column, say column Z from Z1 thru Z100.
And then:

=IF(COUNTIF(Z1:Z100,B2)0,"X","Y")

--
Gary''s Student - gsnu200830


"Chatnoir11" wrote:

Hi. I am doing a simple IF statement with an OR in it.

If(OR(B2="A",B2="B",B2="C"), "X","Y") but I have many more of the OR
criteria, so it takes a long time to type, lots of room for typos.

Is there a more efficient way where I can say, basically if B2 equals
anything in this list, then "X", otherwise "Y"? I tried a dozen variations
but kept getting the "VALUE" error.

Thanks! I do these a lot, so I'd like to speed it up...


Chatnoir11

Embedding an OR statement in an IF statement efficiently
 
Thanks-- this might be simpler for me.

"Dave Peterson" wrote:

=IF(OR(B2={"A","B","C"}),"X","Y")


Chatnoir11 wrote:

Hi. I am doing a simple IF statement with an OR in it.

If(OR(B2="A",B2="B",B2="C"), "X","Y") but I have many more of the OR
criteria, so it takes a long time to type, lots of room for typos.

Is there a more efficient way where I can say, basically if B2 equals
anything in this list, then "X", otherwise "Y"? I tried a dozen variations
but kept getting the "VALUE" error.

Thanks! I do these a lot, so I'd like to speed it up...


--

Dave Peterson



All times are GMT +1. The time now is 02:56 PM.

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