我在 Excel 中使用 IF 语句时不断收到 #VALUE 错误。知道原因吗?任何帮助都将不胜感激!
=IF(
OR(
R2 > 3
),
0,
( IF(
R2 = 1,
( IF(
K2 <- 0.1,
1,
IF(
AND(
K2 >- 0.1,
K2 <- 0.05
),
2,
IF(
AND(
K2 >=- 0.5,
K2 < 0
),
3,
IF(
AND(
K2 >= 0,
K2 <= 0.05
),
4,
IF(
AND(
K2 > 0.05,
K2 <= 0.15
),
5,
IF(
AND(
K2 > 0.15,
K2 <= 0.3
),
6,
7
)
)
)
)
)
) ,
IF(
R2 = 2,
( IF(
K2 <- 0.1,
8,
IF(
AND(
K2 >- 0.1,
K2 <- 0.05
),
9,
IF(
AND(
K2 >=- 0.5,
K2 < 0
),
10,
IF(
AND(
K2 >= 0,
K2 <= 0.05
),
11,
IF(
AND(
K2 > 0.05,
K2 <= 0.15
),
12,
IF(
AND(
K2 > 0.15,
K2 <= 0.3
),
13,
14
)
)
)
)
)
) ,
IF(
R2 = 3,
( IF(
K2 <- 0.1,
15,
IF(
AND(
K2 >- 0.1,
K2 <- 0.05
),
16,
IF(
AND(
K2 >=- 0.5,
K2 < 0
),
17,
IF(
AND(
K2 >= 0,
K2 <= 0.05
),
18,
IF(
AND(
K2 > 0.05,
K2 <= 0.15
),
19,
IF(
AND(
K2 > 0.15,
K2 <= 0.3
),
20,
21
)
)
)
)
)
) )
) )
) )
) )
)
答案1
您的公式非常长,管理如此复杂的公式非常困难。我猜想后面的括号R2=1
只在整个公式的末尾关闭(见下面的注释),导致整个嵌套IF
结构的管理错误。
我建议使用这个公式,以合理的复杂性做同样的事情:
=IF(R2>3,0,IFERROR(MATCH(K2,{-0.1,-0.05,0,0.05,0.15,0.3},1)+1,1)+(R2-1)*7)
原配方:
=IF(
OR(R2>3),
0,
(IF(
R2=1,( ## this bracket is closed only at the end of the formula ##
IF(
K2<-0.1,
1,
IF(
AND(K2>-0.1,K2<-0.05),
2,
IF(
AND(K2>=-0.5,K2<0),
3,
IF(
AND(K2>=0,K2<=0.05),
4,
IF(
AND(K2>0.05,K2<=0.15),
5,
IF(
AND(K2>0.15,K2<=0.3),
6,
7
)
)
)
)
)
),
IF(
R2=2,(
IF(
K2<-0.1,
8,
IF(
AND(K2>-0.1,K2<-0.05),
9,
IF(
AND(K2>=-0.5,K2<0),
10,
IF(
AND(K2>=0,K2<=0.05),
11,
IF(
AND(K2>0.05,K2<=0.15),
12,
IF(
AND(K2>0.15,K2<=0.3),
13,
14
)
)
)
)
),
IF(
R2=3,(
IF(
K2<-0.1,
15,
IF(
AND(K2>-0.1,K2<-0.05),
16,
IF(
AND(K2>=-0.5,K2<0),
17,
IF(
AND(K2>=0,K2<=0.05),
18,
IF(
AND(K2>0.05,K2<=0.15),
19,
IF(
AND(K2>0.15,K2<=0.3),
20,
21
)
)
)
)
)
)
)
)
)
)
)
)
)
)