Xlambda
Well-known Member
- Joined
- Mar 8, 2021
- Messages
- 860
- Office Version
- 365
- Platform
- Windows
AREPLACE !! recursive!! (array replace), replaces all occurrences of "a" found in "ar" with values of "b"
Excel Formula:
=LAMBDA(ar,a,b,
LET(n,ROWS(a),
x,INDEX(a,n),y,INDEX(b,n),
IF(n=1,SUBSTITUTE(ar,x,y),AREPLACE(SUBSTITUTE(ar,x,y),INDEX(a,SEQUENCE(n-1)),INDEX(b,SEQUENCE(n-1))))
)
)
LAMBDA 6.0.xlsx | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | |||
1 | Sample | Lambda that appends string values of an array with its PROPER values. | |||||||||||||||||||||
2 | =IF(SEQUENCE(7),"Aaa aaa Bbb bbb Ccc ccc Ddd ddd") | T_PROPER(a)=LAMBDA(a,LET(x,IF(ROWS(a)=1,TRANSPOSE(a),a),p,PROPER(a),n,ROWS(x),s,SEQUENCE(2*n)-n,IF(s<=0,x,INDEX(p,s)))) | |||||||||||||||||||||
3 | Aaa aaa Bbb bbb Ccc ccc Ddd ddd | ||||||||||||||||||||||
4 | Aaa aaa Bbb bbb Ccc ccc Ddd ddd | replace | aaa | bbb | ccc | ddd | |||||||||||||||||
5 | Aaa aaa Bbb bbb Ccc ccc Ddd ddd | with | xx | yy | zz | ww | |||||||||||||||||
6 | Aaa aaa Bbb bbb Ccc ccc Ddd ddd | ||||||||||||||||||||||
7 | Aaa aaa Bbb bbb Ccc ccc Ddd ddd | I12 | =T_PROPER(J4:M4) | ||||||||||||||||||||
8 | Aaa aaa Bbb bbb Ccc ccc Ddd ddd | J12 | =T_PROPER(J5:M5) | ||||||||||||||||||||
9 | Aaa aaa Bbb bbb Ccc ccc Ddd ddd | ||||||||||||||||||||||
10 | =AREPLACE(A3#,T_PROPER(C14:C17),T_PROPER(D14:D17)) | ||||||||||||||||||||||
11 | =AREPLACE(A3#,C14:C17,D14:D17) | Xx xx Yy yy Zz zz Ww ww | rpl P | with P | |||||||||||||||||||
12 | Aaa xx Bbb yy Ccc zz Ddd ww | Xx xx Yy yy Zz zz Ww ww | aaa | xx | |||||||||||||||||||
13 | Aaa xx Bbb yy Ccc zz Ddd ww | replace | with | Xx xx Yy yy Zz zz Ww ww | bbb | yy | |||||||||||||||||
14 | Aaa xx Bbb yy Ccc zz Ddd ww | aaa | xx | Xx xx Yy yy Zz zz Ww ww | ccc | zz | |||||||||||||||||
15 | Aaa xx Bbb yy Ccc zz Ddd ww | bbb | yy | Xx xx Yy yy Zz zz Ww ww | ddd | ww | |||||||||||||||||
16 | Aaa xx Bbb yy Ccc zz Ddd ww | ccc | zz | Xx xx Yy yy Zz zz Ww ww | Aaa | Xx | |||||||||||||||||
17 | Aaa xx Bbb yy Ccc zz Ddd ww | ddd | ww | Xx xx Yy yy Zz zz Ww ww | Bbb | Yy | |||||||||||||||||
18 | Aaa xx Bbb yy Ccc zz Ddd ww | Ccc | Zz | ||||||||||||||||||||
19 | Ddd | Ww | |||||||||||||||||||||
20 | =AREPLACE(A3#,AFLATTEN(C23:D24),E23:E26) | ||||||||||||||||||||||
21 | Aaa xx Bbb yy Ccc zz Ddd ww | ||||||||||||||||||||||
22 | Aaa xx Bbb yy Ccc zz Ddd ww | replace | with | ||||||||||||||||||||
23 | Aaa xx Bbb yy Ccc zz Ddd ww | aaa | bbb | xx | |||||||||||||||||||
24 | Aaa xx Bbb yy Ccc zz Ddd ww | ccc | ddd | yy | |||||||||||||||||||
25 | Aaa xx Bbb yy Ccc zz Ddd ww | zz | |||||||||||||||||||||
26 | Aaa xx Bbb yy Ccc zz Ddd ww | ww | |||||||||||||||||||||
27 | Aaa xx Bbb yy Ccc zz Ddd ww | ||||||||||||||||||||||
28 | |||||||||||||||||||||||
AREPLACE post |
Cell Formulas | ||
---|---|---|
Range | Formula | |
A2,A20,G10,A11 | A2 | =FORMULATEXT(A3) |
A3:A9 | A3 | =IF(SEQUENCE(7),"Aaa aaa Bbb bbb Ccc ccc Ddd ddd") |
I7 | I7 | =FORMULATEXT(I12) |
I8 | I8 | =FORMULATEXT(J12) |
G11:G17 | G11 | =AREPLACE(A3#,T_PROPER(C14:C17),T_PROPER(D14:D17)) |
A12:A18 | A12 | =AREPLACE(A3#,C14:C17,D14:D17) |
I12:I19 | I12 | =T_PROPER(J4:M4) |
J12:J19 | J12 | =T_PROPER(J5:M5) |
A21:A27 | A21 | =AREPLACE(A3#,AFLATTEN(C23:D24),E23:E26) |
Dynamic array formulas. |
Upvote
0