开发者

How to simplify an Excel IF/OR statement

How can I simplify this with VLOOKUP or LOOKUP?

IF(OR(A1=1,A1=2,A1=3,A1=4,A1=5,A1=6,A1=7),"Yes","No")

is there any way to make it more robust using VLOOKUP or any other Excel function to avoid this many or cond开发者_如何学Citions?


Basically that OR condition is the same as A1<8 so just do that and get rid of the OR.

=IF(A1<8,"Yes","No")

in this example i have a list in Sheet 2 in the A column that contains all the values. In sheet 1 in cell A1 I enter the test number and you can put this formula in any cell you want

=IF(LOOKUP(A1,Sheet2!A:A,Sheet2!A:A)=A1,"Yes","No")


A bit better:

=IF(ISERROR(FIND("|"&A1&"|", "|1|2|3|4|5|6|7|")), "No", "Yes")

Assumes no one ever puts "|" into A1


This is the same:

=IF(AND(A1>0,A1<8,INT(A1)=A1),"Yes","No")


If I'm understanding correctly, you have a value in cell, say A1, and a variety of other values in cells B1:B8 and you'd like to know whether A1 matches any value present in B1:B8.

You could set up a flag variable taking value 1 if a match is found and 0 if not as follows: =1-ISNA(MATCH(A1,B1:B8,0))

Alternatively, you could do something like: =IF(ISNA(MATCH(A1,B1:B8,0)),"No","Yes") to output something more similar to the above.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜