In column A i have a long text, containing substrings that you can find on another range (column D). I want to search for the substring and if I find it then replace it with the value in column E.
Any help will be much appreciated.
In column A i have a long text, containing substrings that you can find on another range (column D). I want to search for the substring and if I find it then replace it with the value in column E.
Any help will be much appreciated.
If you have Excel 365 you can use this formula in column B:
=LET(mapping, tblMapping,
REDUCE([@text],INDEX(mapping,,1)
LAMBDA(a,b,SUBSTITUTE(a,b,XLOOKUP(b,INDEX(mapping,,1),INDEX(mapping,,2))))))
This will also work if there are two or more relevant texts - s. last row
Don't forget to apply "wrap text" to column B.
EDIT according to question in comments: You can use this formula to return true / false depending on wether at least one text has been found:
=REDUCE(FALSE,tblMapping[Text to search],
LAMBDA(a,b,IF(a=TRUE,a,IFERROR(FIND(b,[@text])>0,FALSE))))
You could try using the following formula, which is based on your data presented on the screenshot above.
• Formula used in cell B3
=LET(
a,[@Text],
b,FILTER(Table2,ISNUMBER(FIND(Table2[Text to search],a))),
c,INDEX(b,,1),
d,INDEX(b,,2),
IFERROR(SUBSTITUTE(a,c,d),a))
Since in one of the cells you are using line-feed, hence please remember to use wrap text, by hitting ALT+H+W for the desired result column.