简体   繁体   中英

Trouble using multiple IF statements in Excel

The formula I'm currently using is

=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,)))))

However, now I need to include an additional condition at the beginning that seems to be a step too far for the formula to calculate - IF(K6="SF", W6*25.4+100) . If K6 does not =SF then I need it to carry on with the formula as usual.

I've tried juggling it around multiple different ways, but I just can't get it to work. Is it possible?

This becomes easier to deal with if you format (and indent) your formula like code.

Here's your existing formula:

=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,)
            )
        )
    )
)

Now we can add the additional IF statement:

=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,)
                )
            )
        )
    )
)

Just to add that new condition, you could use:

=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,))))))

I haven't addressed the fact that you haven't provided an else option for all your IF functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM