Xlambda
Well-known Member
- Joined
- Mar 8, 2021
- Messages
- 837
- Office Version
- 365
- Platform
- Windows
APPENDNHV !! recursive !! appends N arrays horizontally or vertically , calls the other 2 recursive APPEND2H and APPEND2V .
Uses the second syntax of INDEX, INDEX(reference, row_num, [column_num], [area_num]) , so carrys its restrictions (reference argument instead of arrays, arrays should be in the same spreadsheet).
It is a single formula for both directions and for that has an extra argument hv . If you want to eliminate this and have instead 2 separate formulas , use these ones:
APPENDNH(ai,a,i)=LAMBDA(ai,a,i,LET(k,AREAS(a),j,MAX(i,1),IF(j=k+1,ai,APPENDNH(APPEND2H(ai,INDEX(a,,,j),),a,j+1))))
APPENDNV(ai,a,i)=LAMBDA(ai,a,i,LET(k,AREAS(a),j,MAX(i,1),IF(j=k+1,ai,APPENDNV(APPEND2V(ai,INDEX(a,,,j),),a,j+1)))) also recursive ofcourse.
Uses the second syntax of INDEX, INDEX(reference, row_num, [column_num], [area_num]) , so carrys its restrictions (reference argument instead of arrays, arrays should be in the same spreadsheet).
It is a single formula for both directions and for that has an extra argument hv . If you want to eliminate this and have instead 2 separate formulas , use these ones:
APPENDNH(ai,a,i)=LAMBDA(ai,a,i,LET(k,AREAS(a),j,MAX(i,1),IF(j=k+1,ai,APPENDNH(APPEND2H(ai,INDEX(a,,,j),),a,j+1))))
APPENDNV(ai,a,i)=LAMBDA(ai,a,i,LET(k,AREAS(a),j,MAX(i,1),IF(j=k+1,ai,APPENDNV(APPEND2V(ai,INDEX(a,,,j),),a,j+1)))) also recursive ofcourse.
Excel Formula:
=LAMBDA(ai,a,hv,i,
LET(k,AREAS(a),
x,OR(hv={"h","v"}),j,MAX(i,1),
IF(j=k+1,IF(x,ai,"''h''or''v''only"),APPENDNHV(IF(hv="h",APPEND2H(ai,INDEX(a,,,j),),APPEND2V(ai,INDEX(a,,,j),)),a,hv,j+1))
)
)
| LAMBDA 5.0.xlsm | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | |||
| 1 | a1 - 1 | a1 - 2 | a2 - 1 | a2 - 2 | a3 - 1 | a3 - 2 | a3 - 3 | a4 - 1 | a4 - 2 | a5 - 1 | a5 - 2 | |||||||
| 2 | a1 - 3 | a1 - 4 | a2 - 3 | a2 - 4 | a3 - 4 | a3 - 5 | a3 - 6 | a4 - 3 | a4 - 4 | a5 - 3 | a5 - 4 | |||||||
| 3 | a1 - 5 | a1 - 6 | a4 - 5 | a4 - 6 | a5 - 5 | a5 - 6 | ||||||||||||
| 4 | a4 - 7 | a4 - 8 | a5 - 7 | a5 - 8 | ||||||||||||||
| 5 | ||||||||||||||||||
| 6 | =APPENDNHV(A1#,(D1#,G1#,K1#,N1#),"h",) | |||||||||||||||||
| 7 | a1 - 1 | a1 - 2 | a2 - 1 | a2 - 2 | a3 - 1 | a3 - 2 | a3 - 3 | a4 - 1 | a4 - 2 | a5 - 1 | a5 - 2 | |||||||
| 8 | a1 - 3 | a1 - 4 | a2 - 3 | a2 - 4 | a3 - 4 | a3 - 5 | a3 - 6 | a4 - 3 | a4 - 4 | a5 - 3 | a5 - 4 | |||||||
| 9 | a1 - 5 | a1 - 6 | a4 - 5 | a4 - 6 | a5 - 5 | a5 - 6 | ||||||||||||
| 10 | a4 - 7 | a4 - 8 | a5 - 7 | a5 - 8 | ||||||||||||||
| 11 | ||||||||||||||||||
| 12 | i=3 | =APPENDNHV(A1#,(D1#,G1#,K1#,N1#),"h",3) | =APPENDNHV(SEQUENCE(4,,"17-03-21"),(D1#,G1#,K1#,N1#),"h",3) | |||||||||||||||
| 13 | a1 - 1 | a1 - 2 | a4 - 1 | a4 - 2 | a5 - 1 | a5 - 2 | 17-03-21 | a4 - 1 | a4 - 2 | a5 - 1 | a5 - 2 | |||||||
| 14 | a1 - 3 | a1 - 4 | a4 - 3 | a4 - 4 | a5 - 3 | a5 - 4 | 18-03-21 | a4 - 3 | a4 - 4 | a5 - 3 | a5 - 4 | |||||||
| 15 | a1 - 5 | a1 - 6 | a4 - 5 | a4 - 6 | a5 - 5 | a5 - 6 | 19-03-21 | a4 - 5 | a4 - 6 | a5 - 5 | a5 - 6 | |||||||
| 16 | a4 - 7 | a4 - 8 | a5 - 7 | a5 - 8 | 20-03-21 | a4 - 7 | a4 - 8 | a5 - 7 | a5 - 8 | |||||||||
| 17 | ||||||||||||||||||
| 18 | =APPENDNHV(A1#,(D1#,G1#,K1#,N1#),"v",) | =APPENDNHV("Clm-"&SEQUENCE(,2),(D1#,G1#,K1#,N1#),"v",3) | ||||||||||||||||
| 19 | a1 - 1 | a1 - 2 | Clm-1 | Clm-2 | ||||||||||||||
| 20 | a1 - 3 | a1 - 4 | a4 - 1 | a4 - 2 | ||||||||||||||
| 21 | a1 - 5 | a1 - 6 | i=3 | a4 - 3 | a4 - 4 | |||||||||||||
| 22 | a2 - 1 | a2 - 2 | =APPENDNHV(A1#,(D1#,G1#,K1#,N1#),"v",3) | a4 - 5 | a4 - 6 | |||||||||||||
| 23 | a2 - 3 | a2 - 4 | a1 - 1 | a1 - 2 | a4 - 7 | a4 - 8 | ||||||||||||
| 24 | a3 - 1 | a3 - 2 | a3 - 3 | a1 - 3 | a1 - 4 | a5 - 1 | a5 - 2 | |||||||||||
| 25 | a3 - 4 | a3 - 5 | a3 - 6 | a1 - 5 | a1 - 6 | a5 - 3 | a5 - 4 | |||||||||||
| 26 | a4 - 1 | a4 - 2 | a4 - 1 | a4 - 2 | a5 - 5 | a5 - 6 | ||||||||||||
| 27 | a4 - 3 | a4 - 4 | a4 - 3 | a4 - 4 | a5 - 7 | a5 - 8 | ||||||||||||
| 28 | a4 - 5 | a4 - 6 | a4 - 5 | a4 - 6 | ||||||||||||||
| 29 | a4 - 7 | a4 - 8 | a4 - 7 | a4 - 8 | ||||||||||||||
| 30 | a5 - 1 | a5 - 2 | a5 - 1 | a5 - 2 | ||||||||||||||
| 31 | a5 - 3 | a5 - 4 | a5 - 3 | a5 - 4 | ||||||||||||||
| 32 | a5 - 5 | a5 - 6 | a5 - 5 | a5 - 6 | ||||||||||||||
| 33 | a5 - 7 | a5 - 8 | a5 - 7 | a5 - 8 | ||||||||||||||
| 34 | ||||||||||||||||||
AAPPENDH | ||||||||||||||||||
| Cell Formulas | ||
|---|---|---|
| Range | Formula | |
| A1:B3 | A1 | ="a1 - "&SEQUENCE(3,2) |
| D1:E2 | D1 | ="a2 - "&SEQUENCE(2,2) |
| G1:I2 | G1 | ="a3 - "&SEQUENCE(2,3) |
| K1:L4 | K1 | ="a4 - "&SEQUENCE(4,2) |
| N1:O4 | N1 | ="a5 - "&SEQUENCE(4,2) |
| A6,E22,A18,I12 | A6 | =FORMULATEXT(A7) |
| A7:K10 | A7 | =APPENDNHV(A1#,(D1#,G1#,K1#,N1#),"h",) |
| B12 | B12 | =FORMULATEXT(A13) |
| A13:F16 | A13 | =APPENDNHV(A1#,(D1#,G1#,K1#,N1#),"h",3) |
| I13:M16 | I13 | =APPENDNHV(SEQUENCE(4,,"17-03-21"),(D1#,G1#,K1#,N1#),"h",3) |
| I18 | I18 | =FORMULATEXT(K19) |
| A19:C33 | A19 | =APPENDNHV(A1#,(D1#,G1#,K1#,N1#),"v",) |
| K19:L27 | K19 | =APPENDNHV("Clm-"&SEQUENCE(,2),(D1#,G1#,K1#,N1#),"v",3) |
| E23:F33 | E23 | =APPENDNHV(A1#,(D1#,G1#,K1#,N1#),"v",3) |
| Dynamic array formulas. | ||
Upvote
0