schardt679
Board Regular
- Joined
- Mar 27, 2021
- Messages
- 58
- Office Version
- 365
- 2010
- Platform
- Windows
- Mobile
- Web
ARESIZE resizes an array given the number of rows and/or columns to add or remove and values to use for new rows/columns.
Thanks to RicoS's RESIZEARRAY function for the inspiration.
If both rows and columns are added, the column value(s) takes precedence. To change this, take the first two conditions of PreRes and Result and swap them
Row_Val can handle multiple values in row format (across columns). Col_Val can handle multiple values in column format (down rows).
Optional arguments require comma to work. Calls CELLCOUNT & ACONSTANT.
Other functions on minisheet: AFORMULATEXT.
Screen Tip/ Comment: =ARESIZE(Array☛ range, [nRow_Top]☛ #⇧R; =0, [nRow_Bottom]☛ #⇩R; =0, [nCol_Left]☛ #⇦C; =0, [nCol_Right]☛ #⇨C; =0, [Row_Val]☛ R; ="", [Col_Val]☛ C; ="") ⁂[]=optional: use ","; =default; #=±INT; =omit; =value; R/C=Row/Col; ⇧⇩⇦⇨=Loc
Thanks to RicoS's RESIZEARRAY function for the inspiration.
If both rows and columns are added, the column value(s) takes precedence. To change this, take the first two conditions of PreRes and Result and swap them
Row_Val can handle multiple values in row format (across columns). Col_Val can handle multiple values in column format (down rows).
Optional arguments require comma to work. Calls CELLCOUNT & ACONSTANT.
Other functions on minisheet: AFORMULATEXT.
Screen Tip/ Comment: =ARESIZE(Array☛ range, [nRow_Top]☛ #⇧R; =0, [nRow_Bottom]☛ #⇩R; =0, [nCol_Left]☛ #⇦C; =0, [nCol_Right]☛ #⇨C; =0, [Row_Val]☛ R; ="", [Col_Val]☛ C; ="") ⁂[]=optional: use ","; =default; #=±INT; =omit; =value; R/C=Row/Col; ⇧⇩⇦⇨=Loc
Excel Formula:
=LAMBDA(Array,nRow_Top,nRow_Bottom,nCol_Left,nCol_Right,Row_Val,Col_Val,
LET(Arr, Array, nRowT, MAX(N(IFERROR(nRow_Top,))), nRowB, MAX(N(IFERROR(nRow_Bottom,))),
nColL, MAX(N(IFERROR(nCol_Left,))), nColR, MAX(N(IFERROR(nCol_Right,))),
RowCt, CELLCOUNT(Arr, 1), RowAdd, nRowT+nRowB, ColCt, CELLCOUNT(Arr, 2), ColAdd, nColL+nColR,
NumScan, OR(RowAdd<=-RowCt, ColAdd<=-ColCt), NumMSG, "Remove less rows/columns",
RowSeq, SEQUENCE(RowCt+RowAdd), ColSeq, SEQUENCE(, ColCt+ColAdd),
RowVal, ACONSTANT(Row_Val,, ColSeq), ColVal, ACONSTANT(Col_Val, RowSeq,),
RowValColCt, CELLCOUNT(RowVal, 2), ColValRowCt, CELLCOUNT(ColVal, 1),
RowValScan, ColSeq>RowValColCt, ColValScan, RowSeq> ColValRowCt,
PreRowT, ACONSTANT(RowVal, nRowT,), PreRowB, ACONSTANT(RowVal, nRowB,),
PreColL, ACONSTANT(ColVal,, nColL), PreColR, ACONSTANT(ColVal,, nColR),
ValRowT, INDEX(PreRowT, RowSeq, ColSeq), ValRowB, INDEX(PreRowB, RowSeq-RowCt-nRowT, ColSeq),
ValColL, INDEX(PreColL, RowSeq, ColSeq), ValColR, INDEX(PreColR, RowSeq, ColSeq-ColCt-nColL),
ValArr, INDEX(IF(Arr="", "", Arr), RowSeq-nRowT, ColSeq-nColL),
PreRes, IFS(RowSeq<=nRowT, IF(RowValScan, "", ValRowT), RowSeq>RowCt+nRowT, IF(RowValScan, "", ValRowB), 1, ValArr),
Result, IFS(ColSeq<=nColL, IF(ColValScan, "", ValColL), ColSeq>ColCt+nColL, IF(ColValScan, "", ValColR), 1, PreRes),
Return, IF(NumScan, NumMSG, Result),
Return
)
)
LAMBDA Examples.xlsx | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | |||
1 | ARESIZE | ||||||||||||||
2 | Sample Data | Rows_Top: | 1 | Result | |||||||||||
3 | Apple | Watermelon | Pineapple | Rows_Bottom: | Fruit | Fruit | Fruit | ||||||||
4 | Banana | Apple | Columns_Left: | 1 | Apple | Watermelon | Pineapple | ||||||||
5 | #N/A | Pear | Grape | Columns_Right: | Banana | Apple | |||||||||
6 | Pineapple | Banana | Pear | Row_Value: | Fruit | #N/A | Pear | Grape | |||||||
7 | Column_Value: | Pineapple | Banana | Pear | |||||||||||
8 | |||||||||||||||
9 | 1 row is added to the top and 0 rows are added to the bottom. | ||||||||||||||
10 | 1 column is added to the left and 0 columns are added to the right. | ||||||||||||||
11 | The new row value is a single repeated value. | ||||||||||||||
12 | The new column value is an empty string. | ||||||||||||||
13 | =ARESIZE(B3:D6, G2, G3, G4, G5, G6, G7) | ||||||||||||||
14 | |||||||||||||||
15 | |||||||||||||||
16 | |||||||||||||||
17 | Sample Data | Rows_Top: | Result | ||||||||||||
18 | Apple | Watermelon | Pineapple | Rows_Bottom: | -1 | Apple | Watermelon | Pineapple | Lemon | ||||||
19 | Banana | Apple | Columns_Left: | Banana | Apple | Canteloupe | |||||||||
20 | #N/A | Pear | Grape | Columns_Right: | 1 | #N/A | Pear | Grape | Honeydew | ||||||
21 | Pineapple | Banana | Pear | Row_Value: | Fruit | ||||||||||
22 | Column_Value: | Lemon | |||||||||||||
23 | Canteloupe | ||||||||||||||
24 | 0 rows are added to the top and 1 row is removed from the bottom. | Honeydew | |||||||||||||
25 | 0 columns are added to the left and 1 column is added to the right. | ||||||||||||||
26 | The new row value is a single repeated value. | ||||||||||||||
27 | The new column value is an array of values | ||||||||||||||
28 | =ARESIZE(B18:D21, G17, G18, G19, G20, G21, G22:G24) | ||||||||||||||
29 | |||||||||||||||
30 | |||||||||||||||
31 | |||||||||||||||
32 | Sample Data | Rows_Top: | -1 | Result | |||||||||||
33 | Apple | Watermelon | Pineapple | Rows_Bottom: | 2 | 1 | Banana | Apple | |||||||
34 | Banana | Apple | Columns_Left: | 1 | 2 | #N/A | Pear | Grape | |||||||
35 | #N/A | Pear | Grape | Columns_Right: | 3 | Pineapple | Banana | Pear | |||||||
36 | Pineapple | Banana | Pear | Row_Value: | Apple | Apple | Apple | Apple | |||||||
37 | Column_Value: | 1 | Apple | Apple | Apple | ||||||||||
38 | 2 | ||||||||||||||
39 | 1 row is removed from the top and 2 rows are added to the bottom. | 3 | |||||||||||||
40 | 1 column is added to the left and 0 columns are added to the right. | ||||||||||||||
41 | The new row value is a single repeated value. | ||||||||||||||
42 | The new column value is an array of values | ||||||||||||||
43 | =ARESIZE(B33:D36, G32, G33, G34, G35, G36, G37:G39) | ||||||||||||||
44 | |||||||||||||||
ARESIZE |
Cell Formulas | ||
---|---|---|
Range | Formula | |
I3:L7 | I3 | =ARESIZE(B3:D6, G2, G3, G4, G5, G6, G7) |
B13,B43,B28 | B13 | =FORMULATEXT(I3) |
I18:L20,I33:L37 | I18 | =ARESIZE(B18:D21, G17, G18, G19, G20, G21, G22:G24) |
Dynamic array formulas. |
Last edited:
Upvote
0