EXCEL中, A1为1或3,B1显示100;A1为2或4,B1显示200, A1为0或5,B1显示300. 这公式如何写?

2024-11-26 01:44:21
推荐回答(5个)
回答1:

B1公式
=IF(OR(A1={1,3}),100,IF(OR(A1={2,4}),200,300))
如果A1值超出上面的值给出错误提示,可以把公式改为
=IF(OR(A1={1,3}),100,IF(OR(A1={2,4}),200,IF(OR(A1={0,5}),300,"有误")))

也可以用CHOOSE、VLOOKUP更简单,比如
=CHOOSE(A1+1,300,100,200,100,200,300)
=CHOOSE(A1+1,3,1,2,1,2,3)*100

回答2:

B1公式如下:
=IF(A1<>"",IF(A1=1,100,IF(A1=3,100,IF(A1=2,200,IF(A1=4,200,IF(A1=0,300,IF(A1=5,300,"")))))),"")

解释如下:
如果A1不为空,则 A1为1或3,B1显示100;A1为2或4,B1显示200, A1为0或5,B1显示300,
否则,B1显示为空

回答3:

=IF(A1=1,"100",IF(A1=3,"100",IF(A1=2,"200",IF(A1=4,"200",IF(A1=5,"300",IF(A1=0,"300"))))))

回答4:

=IF(OR(A1=1,A1=3),100,IF(OR(A1=2,A1=4),200,IF(OR(A1=0,A1=5),300,"")))

回答5:

=IF(OR(A1=1,A1=3),100,IF(OR(A1=2,A1=4),200,IF(OR(A1=0,A1=5),300,)))