在Excel中使用多个IF语句出现问题

时间:2018-11-05 09:58:42

标签: excel

我当前使用的公式是

=IF($X$4="in",IF(OR(T6="PLATE", T6="EXTR", T6="FLAT"),W7*25.4+10,IF(T6="SHEET",W7*25.4+50,IF(T6="ROUND",ROUNDUP(W7*25.4+8,)))), IF(OR(T6="PLATE", T6="EXTR", T6="FLAT"),W7+10,IF(T6="SHEET",W7+50,IF(T6="ROUND",ROUNDUP(W7+8,)))))

但是,现在我需要在开始时添加一个附加条件,对于公式计算- IF(K6="SF", W6*25.4+100)来说,这似乎是一个步骤。如果K6=SF,那么我需要它像往常一样继续进行公式。

我尝试过多种方法来处理它,但是我无法使其正常工作。有可能吗?

2 个答案:

答案 0 :(得分:3)

如果您格式化(和缩进)代码之类的公式,这将变得更容易处理。

这是您现有的公式:

=IF(
    $X$4="in",
    IF(
        OR(
            T6="PLATE", 
            T6="EXTR", 
            T6="FLAT"
        ),
        W7*25.4+10,
        IF(
            T6="SHEET",
            W7*25.4+50,
            IF(
                T6="ROUND",
                ROUNDUP(W7*25.4+8,)
            )
        )
    ),
    IF(
        OR(
            T6="PLATE", 
            T6="EXTR", 
            T6="FLAT"
        ),
        W7+10,
        IF(
            T6="SHEET",
            W7+50,
            IF(
                T6="ROUND",
                ROUNDUP(W7+8,)
            )
        )
    )
)

现在,我们可以添加其他IF语句:

=IF(
    K6="SF", 
    W6*25.4+100,
    IF(
        $X$4="in",
        IF(
            OR(
                T6="PLATE", 
                T6="EXTR", 
                T6="FLAT"
            ),
            W7*25.4+10,
            IF(
                T6="SHEET",
                W7*25.4+50,
                IF(
                    T6="ROUND",
                    ROUNDUP(W7*25.4+8,)
                )
            )
        ),
        IF(
            OR(
                T6="PLATE", 
                T6="EXTR", 
                T6="FLAT"
            ),
            W7+10,
            IF(
                T6="SHEET",
                W7+50,
                IF(
                    T6="ROUND",
                    ROUNDUP(W7+8,)
                )
            )
        )
    )
)

答案 1 :(得分:0)

只需添加新条件,您就可以使用:

=IF(K6="SF", W6*25.4+100,IF($X$4="in",IF(OR(T6={"PLATE","EXTR","FLAT"}),W7*25.4+10,IF(T6="SHEET",W7*25.4+50,IF(T6="ROUND",ROUNDUP(W7*25.4+8,)))), IF(OR(T6={"PLATE","EXTR","FLAT"}),W7+10,IF(T6="SHEET",W7+50,IF(T6="ROUND",ROUNDUP(W7+8,))))))

我还没有解决您尚未为所有IF函数提供 else 选项的事实。