Forum Discussion

githinmg99's avatar
githinmg99
Copper Contributor
Jul 15, 2022
Solved

Formula to edit part of a text in one cell based on an values in another cell

Hi guys, I'm looking for a formula for one of my projects which can help in removing certain parts of a cell (Cell A - names separated by a 😉 based on the values in Cell B (similar format as Cell A)...
  • Lorenzo's avatar
    Lorenzo
    Jul 17, 2022

    githinmg99 

    In attached file, a different approach for TEXT_SPLIT:

    =LAMBDA(Value,Delimiter,
        LET(
            Positions, LAMBDA(String,Delim,Sequence,
                LET(
                    k, SCAN(0,Sequence, LAMBDA(acc,s, IF(MID(String,s,1)=Delim, acc+s, 0))),
                    FILTER(k, k > 0)
                )
            ),
            Seq,   SEQUENCE(LEN(Value)+1),
            Start, Positions(Delimiter & Value, Delimiter, Seq),
            End,   Positions(Value & Delimiter, Delimiter, Seq),
            MID(Value, Start, End-Start)
        )
    )

     

    Updated previous Result formula to account for nothing to return and added a couple of other options that avoid spliting A2 (better IMHO)

    in D2:

    =LET(
        value, TEXT_SPLIT(A2,";"),
        TEXTJOIN(";",,FILTER(value,ISNA(XMATCH(value,TEXT_SPLIT(B2,";"))),""))
    )

    in F2:

    =LET(
        Removed, REDUCE(A2&";",TEXT_SPLIT(B2,";"),
                    LAMBDA(value,arr, SUBSTITUTE(value,arr&";",""))
        ),
        IF(LEN(Removed) = 0, "", LEFT(Removed, LEN(Removed)-1))
    )

    in H2:

    =LET(
        Removed, REDUCE(LOWER(A2)&";",TEXT_SPLIT(LOWER(B2),";"),
                    LAMBDA(value,arr, SUBSTITUTE(value,arr&";",""))
        ),
        IF(LEN(Removed) = 0, "", LEFT(Removed, LEN(Removed)-1))
    )

     

Resources