Xlambda
Well-known Member
- Joined
- Mar 8, 2021
- Messages
- 860
- Office Version
- 365
- Platform
- Windows
ARRANGE array arrange, rearranges columns of an array from left to right in any order.
Example: Lets consider "a" a 5 columns array. ARRANGE(a,{4,2}) will rearrange the columns indexes in this order from left to right 4,2 , and to follow, the remaining indexes in ascending order from left to right. Final outcome : 4,2,1,3,5
o: order argument, integer or array of integers. >=1. 2 or {4,2} . can not be 0 or ignored
Example: Lets consider "a" a 5 columns array. ARRANGE(a,{4,2}) will rearrange the columns indexes in this order from left to right 4,2 , and to follow, the remaining indexes in ascending order from left to right. Final outcome : 4,2,1,3,5
o: order argument, integer or array of integers. >=1. 2 or {4,2} . can not be 0 or ignored
Excel Formula:
=LAMBDA(a,o,
LET(c,COLUMNS(a),l,COLUMNS(o),r,ROWS(a),w,SEQUENCE(r),s,SEQUENCE(,c),
x,FILTER(s,ISNA(XMATCH(s,o))),y,INDEX(a,w,IF(s<=l,o,INDEX(x,s-l))),z,AND(ISNUMBER(XMATCH(o,s))),
IF(NOT(z),"check order",y)
)
)
LAMBDA 7.0.xlsx | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | |||
1 | sample | =ARRANGE(A2:D10,2) | =ARRANGE(A2:D10,{2,4}) | =ARRANGE(A2:D10,{2,5}) | ||||||||||||||||
2 | Code | Product | Price | Color | Product | Code | Price | Color | Product | Color | Code | Price | check order | |||||||
3 | CR-r | Carlota | 26 | Red | Carlota | CR-r | 26 | Red | Carlota | Red | CR-r | 26 | ||||||||
4 | KK-b | Kiki | 13 | Blue | Kiki | KK-b | 13 | Blue | Kiki | Blue | KK-b | 13 | (5 is out of range | |||||||
5 | QD-r | Quad | 43 | Red | Quad | QD-r | 43 | Red | Quad | Red | QD-r | 43 | of total 4 clms) | |||||||
6 | SH-r | Sunshine | 19 | Red | Sunshine | SH-r | 19 | Red | Sunshine | Red | SH-r | 19 | ||||||||
7 | CR-g | Carlota | 24 | Green | Carlota | CR-g | 24 | Green | Carlota | Green | CR-g | 24 | =ARRANGE(A2:D10,) | |||||||
8 | QD-b | Quad | 41 | Blue | Quad | QD-b | 41 | Blue | Quad | Blue | QD-b | 41 | check order | |||||||
9 | SH-b | Sunshine | 18 | Blue | Sunshine | SH-b | 18 | Blue | Sunshine | Blue | SH-b | 18 | ||||||||
10 | KK-r | Kiki | 20 | Red | Kiki | KK-r | 20 | Red | Kiki | Red | KK-r | 20 | (order argument | |||||||
11 | can not be ignored or 0) | |||||||||||||||||||
12 | to leave array unchanged o=1 | |||||||||||||||||||
13 | =ARRANGE(A2:D10,1) | =ARRANGE(A2:D10,{2,4,3}) | ||||||||||||||||||
14 | Code | Product | Price | Color | Product | Color | Price | Code | ||||||||||||
15 | CR-r | Carlota | 26 | Red | Carlota | Red | 26 | CR-r | ||||||||||||
16 | KK-b | Kiki | 13 | Blue | Kiki | Blue | 13 | KK-b | ||||||||||||
17 | QD-r | Quad | 43 | Red | Quad | Red | 43 | QD-r | ||||||||||||
18 | SH-r | Sunshine | 19 | Red | Sunshine | Red | 19 | SH-r | ||||||||||||
19 | CR-g | Carlota | 24 | Green | Carlota | Green | 24 | CR-g | ||||||||||||
20 | QD-b | Quad | 41 | Blue | Quad | Blue | 41 | QD-b | ||||||||||||
21 | SH-b | Sunshine | 18 | Blue | Sunshine | Blue | 18 | SH-b | ||||||||||||
22 | KK-r | Kiki | 20 | Red | Kiki | Red | 20 | KK-r | ||||||||||||
23 | ||||||||||||||||||||
ARRANGE post |
Cell Formulas | ||
---|---|---|
Range | Formula | |
F1,K13,F13,P7,P1,K1 | F1 | =FORMULATEXT(F2) |
F2:I10 | F2 | =ARRANGE(A2:D10,2) |
K2:N10 | K2 | =ARRANGE(A2:D10,{2,4}) |
P2 | P2 | =ARRANGE(A2:D10,{2,5}) |
P8 | P8 | =ARRANGE(A2:D10,) |
F14:I22 | F14 | =ARRANGE(A2:D10,1) |
K14:N22 | K14 | =ARRANGE(A2:D10,{2,4,3}) |
Dynamic array formulas. |
Upvote
1