LAMBDA/SUBSTITUTE formula

RonOliver

Board Regular
Joined
Aug 30, 2022
Messages
96
Office Version
  1. 365
Platform
  1. Windows
Hi, geniuses,

This is a formula from long ago:

=SUBSTITUTE(TEXTSPLIT(REDUCE('ED'!A304,'BB'!$A$2:$ZZ$2,LAMBDA(s,r,IF(LEFT(s, LEN(r)+1) = r & " ", r & "#", SUBSTITUTE(s," "&r&" "," "&SUBSTITUTE(r," ","#")&"#"))))," "),"#"," ")

This is how this formula works: In A304, I got a name — "Del Jarro Oxley". In the range in the BB sheet, I got a list of prepositions, among which is "Del". This formula is meant to split A304 into "Del Jarro" and "Oxley". However, because "Del" is at the beginning of the string, the formula is not able to place a # before the word "Del" and will therefore split this into "Del", "Jarro", "Oxley". This formula would have worked, however, had it been "Oxley Del Jarro", as it would have split it into "Oxley" and "Del Jarro". Can you guys give me any ideas to work around this problem? This is actually part of a larger formula, so I would not want to change it entirely unless it is necessary. Thanks! :)
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
This probably does not match your requirement "not to change it entirely":

Excel Formula:
=LET(
array,'ED'!A304,
list,'BB'!$A$2:$ZZ$2,
SUBSTITUTE(DROP(REDUCE("",array,LAMBDA(a,b,VSTACK(a,TEXTSPLIT(SUBSTITUTE(TEXTJOIN(" ",,IFERROR(BYCOL(TEXTSPLIT(b," "),LAMBDA(a,XLOOKUP(a,list,list&"#"))),TEXTSPLIT(b," "))),"# ","#")," ")))),1),"#"," "))
 
Upvote 1
Solution
This probably does not match your requirement "not to change it entirely":

Excel Formula:
=LET(
array,'ED'!A304,
list,'BB'!$A$2:$ZZ$2,
SUBSTITUTE(DROP(REDUCE("",array,LAMBDA(a,b,VSTACK(a,TEXTSPLIT(SUBSTITUTE(TEXTJOIN(" ",,IFERROR(BYCOL(TEXTSPLIT(b," "),LAMBDA(a,XLOOKUP(a,list,list&"#"))),TEXTSPLIT(b," "))),"# ","#")," ")))),1),"#"," "))
Did a short test and it works. You people are amazing. Will test this thoroughly through the weekend and mark this as the solution if it works. Thanks so very much!
 
Upvote 0
Did a short test and it works. You people are amazing. Will test this thoroughly through the weekend and mark this as the solution if it works. Thanks so very much!

Thanks for the feedback; if you encounter a problem we will adjust it or find another solution...
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top