简体   繁体   中英

Excel substituting values and then sumproduct

So I'm currently working on an easier way to plan hours during the week.

What i currently are struggeling with, is that i need to substitute some cells, prior to calculating with them.

在此处输入图像描述

As seen on this picture, the l10->r10 successfully translates the fields at l6->r6.

But now i want it to just write the answer directly, instead of having a seperate field (K10)

Formula on K10:

=LET(range;L10:R10;SUMPRODUCT(MID(SUBSTITUTE(range;".";":");FIND("-";range)+1;LEN(range)) - LEFT(SUBSTITUTE(range;".";":"); FIND("-";range)-1 ))*24)

Formular on L10:

=LET(range;L6:R6; IF(range=""; "0-0"; IF(LOWER(range)="fri";SUBSTITUTE(LOWER(range);"fri";"0-0");SUBSTITUTE(range;".";":")) ))

They successfully work, side by side, but when i try to combine them, it just writes "#value!" if there is an empty cell

It works for me if I just nest the second 'let' within the first 'let' like this

=LET(range,LET(range,L6:R6, IF(range="", "0-0", IF(LOWER(range)="fri",SUBSTITUTE(LOWER(range),"fri","0-0"),SUBSTITUTE(range,".",":")) )),
SUMPRODUCT(MID(SUBSTITUTE(range,".",":"),FIND("-",range)+1,LEN(range)) - LEFT(SUBSTITUTE(range,".",":"), FIND("-",range)-1 ))*24)

or in your locale

=LET(range;LET(range;L6:R6; IF(range=""; "0-0"; IF(LOWER(range)="fri";SUBSTITUTE(LOWER(range);"fri";"0-0");SUBSTITUTE(range;".";":")) ));
SUMPRODUCT(MID(SUBSTITUTE(range;".";":");FIND("-";range)+1;LEN(range)) - LEFT(SUBSTITUTE(range;".";":"); FIND("-";range)-1 ))*24)

在此处输入图像描述

More readable version produced using Advanced Formula Environment :

=
    LET(
        range, LET(
            range, Sheet1!L6:R6,
            IF(
                range = "",
                "0-0",
                IF(LOWER(range) = "fri", SUBSTITUTE(LOWER(range), "fri", "0-0"), SUBSTITUTE(range, ".", ":"))
            )
        ),
        SUMPRODUCT(
            MID(SUBSTITUTE(range, ".", ":"), FIND("-", range) + 1, LEN(range)) -
                LEFT(SUBSTITUTE(range, ".", ":"), FIND("-", range) - 1)
        ) * 24
    )

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