ARESIZE

ARESIZE(Array,nRow_Top,nRow_Bottom,nCol_Left,nCol_Right,Row_Val,Col_Val)
Array
Required. Array to resize
nRow_Top
Optional. Number of rows to add (+) or remove (-) at the top side of the array; ignored☛ 0
nRow_Bottom
Optional. Number of rows to add (+) or remove (-) at the bottom side of the array; ignored☛ 0
nCol_Left
Optional. Number of columns to add (+) or remove (-) at the left side of the array; ignored☛ 0
nCol_Right
Optional. Number of columns to add (+) or remove (-) at the right side of the array; ignored☛ 0
Row_Val
Optional. Value(s) to use for new rows in row format (across columns); ignored☛ empty string
Col_Val
Optional. Value(s) to use for new columns in column format (down rows); ignored☛ empty string

ARESIZE resizes an array given the number of rows and/or columns to add or remove and values to use for new rows/columns.

schardt679

Board Regular
Joined
Mar 27, 2021
Messages
58
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. 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

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
ABCDEFGHIJKLM
1ARESIZE
2Sample DataRows_Top:1Result
3AppleWatermelonPineappleRows_Bottom: FruitFruitFruit
4BananaAppleColumns_Left:1AppleWatermelonPineapple
5#N/APearGrapeColumns_Right:BananaApple
6PineappleBananaPearRow_Value:Fruit#N/APearGrape
7Column_Value:PineappleBananaPear
8
91 row is added to the top and 0 rows are added to the bottom.
101 column is added to the left and 0 columns are added to the right.
11The new row value is a single repeated value.
12The new column value is an empty string.
13=ARESIZE(B3:D6, G2, G3, G4, G5, G6, G7)
14
15
16
17Sample DataRows_Top:Result
18AppleWatermelonPineappleRows_Bottom:-1AppleWatermelonPineappleLemon
19BananaAppleColumns_Left:BananaAppleCanteloupe
20#N/APearGrapeColumns_Right:1#N/APearGrapeHoneydew
21PineappleBananaPearRow_Value:Fruit
22Column_Value:Lemon
23Canteloupe
240 rows are added to the top and 1 row is removed from the bottom.Honeydew
250 columns are added to the left and 1 column is added to the right.
26The new row value is a single repeated value.
27The new column value is an array of values
28=ARESIZE(B18:D21, G17, G18, G19, G20, G21, G22:G24)
29
30
31
32Sample DataRows_Top:-1Result
33AppleWatermelonPineappleRows_Bottom:21BananaApple
34BananaAppleColumns_Left:12#N/APearGrape
35#N/APearGrapeColumns_Right:3PineappleBananaPear
36PineappleBananaPearRow_Value:AppleAppleAppleApple
37Column_Value:1AppleAppleApple
382
391 row is removed from the top and 2 rows are added to the bottom.3
401 column is added to the left and 0 columns are added to the right.
41The new row value is a single repeated value.
42The new column value is an array of values
43=ARESIZE(B33:D36, G32, G33, G34, G35, G36, G37:G39)
44
ARESIZE
Cell Formulas
RangeFormula
I3:L7I3=ARESIZE(B3:D6, G2, G3, G4, G5, G6, G7)
B13,B43,B28B13=FORMULATEXT(I3)
I18:L20,I33:L37I18=ARESIZE(B18:D21, G17, G18, G19, G20, G21, G22:G24)
Dynamic array formulas.
 
Last edited:
Upvote 0
I have been adding screen tips to my LAMBDA functions. Right now, you are limited to 255 characters or less. So I put each function name, argument or note in a separate cell using commas and parentheses when applicable. I combine them using a double space in TEXTJOIN for clarity. Finally I have a small character count check to ensure the comment does not exceed the 255 limit.

LAMBDA Examples.xlsx
NOPQRSTUVWXYZ
47Screen Tip Comment Setup:
48=ARESIZE(Array☛ range,
49[nRow_Top]☛ #⇧R; ❎=0✅,
50[nRow_Bottom]☛ #⇩R; ❎=0✅,
51[nCol_Left]☛ #⇦C; ❎=0✅,
52[nCol_Right]☛ #⇨C; ❎=0✅,
53[Row_Val]☛ R❔; ❎=""✅,
54[Col_Val]☛ C❔; ❎=""✅)
55⁂[]=optional: use ","; ✅=default; #=±INT; ❎=omit; ❔=value; R/C=Row/Col; ⇧⇩⇦⇨=Loc
56
57Screen Tip Comment:
58=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
59
60
61Total Char:252
62
ARESIZE
Cell Formulas
RangeFormula
O58O58=TEXTJOIN(" ",, O48:O55)
P61P61=LEN(O58)
 
ARESIZE has been rewritten. It is a little shorter, takes advantage of the optional argument syntax, and values can now be repeated in a looped manner.

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, Col_Val takes precedence. To change this, swap the first two conditions of PreRes and Result.
Row_Val and Col_Val can handle arrays of values.
Optional arguments require comma to work. Calls IFBLANK, CELLCOUNT & ACONSTANT.
Other functions on minisheet: AFORMULATEXT.

Screen Tip/ Comment: =ARESIZE(Array☛ range, [nRow_Top]☛ #⇧RA; ❎=0✅, [nRow_Bottom]☛ #⇩RA; ❎=0✅, [nCol_Left]☛ #⇦CA; ❎=0✅, [nCol_Right]☛ #⇨CA; ❎=0✅, [Row_Val]☛ R❔; ❎=""✅, [Col_Val]☛ C❔; ❎=""✅) ⁂[]=optional; ✅=default; #=±INT; ❎=omit; ❔=value; A/R/C=Array/Row/Col; ⇧⇩⇦⇨=Loc

The syntax is the same: ARESIZE(Array,[nRow_Top],[nRow_Bottom],[nCol_Left],[nCol_Right],[Row_Val],[Col_Val])

The arguments are the same nut it now repeats the Value argument differently.
1. Single values still repeat across rows and columns.
2. If nRow_Top and/or nRow_Bottom or nCol_Left and/or nCol_Right are greater than Row_Val or Col_Val row or column count, the values are looped until that number is reached.
3. If nRow_Top and/or nRow_Bottom or nCol_Left and/or nCol_Right are less than Row_Val or Col_Val, the values are indexed to that row or column number.
[nRow_Top]: Optional. Number of rows to add (+) or remove (-) at the top side of the array; ignored☛ 0.
[nRow_Bottom]: Optional. Number of rows to add (+) or remove (-) at the bottom side of the array; ignored☛ 0.
[nCol_Left]: Optional. Number of columns to add (+) or remove (-) at the left side of the array; ignored☛ 0.
[nCol_Right]: Optional. Number of columns to add (+) or remove (-) at the right side of the array; ignored☛ 0.
[Row_Val]: Optional. Value(s) to use for new rows in row format (across columns); ignored☛ empty string.
[Col_Val]: Optional. Value(s) to use for new columns in column format (down rows); ignored☛ empty string.

Excel Formula:
=LAMBDA(Array,[nRow_Top],[nRow_Bottom],[nCol_Left],[nCol_Right],[Row_Val],[Col_Val],
      LET(Arr, IFBLANK(Array, ""),          nRowTop, MAX(IFERROR(--(nRow_Top),)),          nRowBot, MAX(IFERROR(--(nRow_Bottom),)),
             nColLef, MAX(IFERROR(--(nCol_Left),)),          nColRig, MAX(IFERROR(--(nCol_Right),)),
             RowCt, CELLCOUNT(Arr, 1),          RowSum, nRowTop+nRowBot,          ColCt, CELLCOUNT(Arr, 2),          ColSum, nColLef+nColRig,
             NumScan, OR(RowSum<=-RowCt,  ColSum<=-ColCt),          NumMSG, "Remove less rows/columns",
             RowSeq, SEQUENCE(RowCt+RowSum),          ColSeq, SEQUENCE(, ColCt+ColSum),
             RowVal, ACONSTANT(Row_Val, RowSeq, ColSeq),          ColVal, ACONSTANT(Col_Val, RowSeq, ColSeq),
             RowTopVal, INDEX(RowVal, RowSeq, ColSeq),          RowBotVal, INDEX(RowVal, RowSeq-RowCt-nRowTop, ColSeq),
             OrgArr, INDEX(Arr, RowSeq-nRowTop, ColSeq-nColLef),
             ColLefVal, INDEX(ColVal, RowSeq, ColSeq),          ColRigVal, INDEX(ColVal, RowSeq, ColSeq-ColCt-nColLef),
             PreRes, IFS(RowSeq<=nRowTop, RowTopVal,  RowSeq>RowCt+nRowTop, RowBotVal,  1, OrgArr),
             Result, IFS(ColSeq<=nColLef, ColLefVal,  ColSeq>ColCt+nColLef, ColRigVal,  1, PreRes),
             Return, IF(NumScan, NumMSG,  Result),
             Return
      )
  )
LAMBDA Examples.xlsx
ABCDEFGHIJKLMN
1ARESIZE
2
3Sample DataRows_Top:1Result
4AppleWatermelonPineappleRows_Bottom: FruitFruitFruit
5BananaAppleColumns_Left:1AppleWatermelonPineapple
6#N/APearGrapeColumns_Right:BananaApple
7PineappleBananaPearRow_Value:Fruit#N/APearGrape
8Column_Value:PineappleBananaPear
9
101 row is added to the top and 0 rows are added to the bottom.
111 column is added to the left and 0 columns are added to the right.
12The new row value is a single repeated value.
13The new column value is an empty string.
14=ARESIZE(B4:D7, G3,, G5,, G7)
15
16
17
18Sample DataRows_Top:Result
19AppleWatermelonPineappleRows_Bottom:-1AppleWatermelonPineappleLemon
20BananaAppleColumns_Left:BananaAppleCanteloupe
21#N/APearGrapeColumns_Right:1#N/APearGrapeHoneydew
22PineappleBananaPearRow_Value:
23Column_Value:Lemon
24Canteloupe
25Honeydew
26
270 rows are added to the top and 1 row is removed from the bottom.
280 columns are added to the left and 1 column is added to the right.
29Since no rows are being Row_Value has been omitted.
30The new column value is a vertical array of values.
31=ARESIZE(B19:D22,, G19,, G21,, G23:G25)
32
33
34
35Sample DataRows_Top:-1Result
36AppleWatermelonPineappleRows_Bottom:2Apple
37BananaAppleColumns_Left:-1PearGrape
38#N/APearGrapeColumns_Right:BananaPear
39PineappleBananaPearRow_Value:CanteloupePeachCanteloupePeach
40Column_Value:CanteloupePeach
41
421 row is removed from the top and 2 rows are added to the bottom.
431 column is removed from the left and 0 columns are added to the right.
44The new row value is a horizontal array of values.
45Since no columns are being added, Column_Value has been omitted.
46=ARESIZE(B36:D39, G35, G36, G37,, G39:H39)
47
48
49
50Sample DataRows_Top:Result
51AppleWatermelonPineappleRows_Bottom:4WatermelonPineappleLemonKiwi
52BananaAppleColumns_Left:-1AppleLimePlum
53#N/APearGrapeColumns_Right:2PearGrapeHoneydewClementine
54PineappleBananaPearRow_Value:CanteloupePeachBananaPearLemonKiwi
55OrangeStrawberryCanteloupePeachLimePlum
56Column_Value:LemonKiwiOrangeStrawberryHoneydewClementine
57LimePlumCanteloupePeachLemonKiwi
58HoneydewClementineOrangeStrawberryLimePlum
59
600 rows are added to the top and 4 rows are added to the bottom.
611 column is removed from the left and 2 columns are added to the right.
62The new row value is a 2D array of values.
63The new column value is a 2D array of values.
64=ARESIZE(B51:D54,, G51, G52, G53, G54:H55, G56:H58)
65
ARESIZE
Cell Formulas
RangeFormula
J4:M8J4=ARESIZE(B4:D7, G3,, G5,, G7)
B14,B46B14=FORMULATEXT(J4)
J19:M21J19=ARESIZE(B19:D22,, G19,, G21,, G23:G25)
B31B31=FORMULATEXT(J19)
J36:K40J36=ARESIZE(B36:D39, G35, G36, G37,, G39:H39)
J51:M58J51=ARESIZE(B51:D54,, G51, G52, G53, G54:H55, G56:H58)
B64B64=FORMULATEXT(J51)
Dynamic array formulas.
 
ARESIZE has been rewritten again. It is a little shorter It should be a lot faster.
With the looping index functionality of ACONSTANT, I realized the following:
1. RowVal was exactly the same as RowTopVal and RowBotVal | ColVal was exactly the same as ColLefVal and ColRigVal
2. They were redundant, so I removed them. This shortened version functions exactly like the previous revision.

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, Col_Val takes precedence. To change this, swap the first two logical_tests & value_if_trues in Result.
Row_Val and Col_Val can handle arrays of values.
Optional arguments require comma to work. Calls IFBLANK, CELLCOUNT & ACONSTANT.
Other functions on minisheet: AFORMULATEXT.

Screen Tip/ Comment: =ARESIZE(Array☛ range, [Num_Top]☛ #⇧RA; ❎=0✅, [Num_Bottom]☛ #⇩RA; ❎=0✅, [Num_Left]☛ #⇦CA; ❎=0✅, [Num_Right]☛ #⇨CA; ❎=0✅, [Row_Val]☛ R❔; ❎=""✅, [Col_Val]☛ C❔; ❎=""✅) ⁂[]=optional; ✅=default; #=±INT; ❎=omit; ❔=value; A/R/C=Array/Row/Col; ⇧⇩⇦⇨=Loc

The syntax is the same: ARESIZE(Array,[Num_Top],[Num_Bottom],[Num_Left],[Num_Right],[Row_Val],[Col_Val])

The arguments are the same but it now repeats the Value arguments differently.
1. Single values still repeat across rows and columns.
2. If Num_Top and/or Num_Bottom or Num_Left and/or Num_Right are greater than Row_Val or Col_Val row or column count, the values are looped until that number is reached.
3. If Num_Top and/or Num_Bottom or Num_Left and/or Num_Right are less than Row_Val or Col_Val, the values are indexed to that row or column number.
[Num_Top]: Optional. Number of rows to add (+) or remove (-) at the top side of the array; ignored☛ 0.
[Num_Bottom]: Optional. Number of rows to add (+) or remove (-) at the bottom side of the array; ignored☛ 0.
[Num_Left]: Optional. Number of columns to add (+) or remove (-) at the left side of the array; ignored☛ 0.
[Num_Right]: Optional. Number of columns to add (+) or remove (-) at the right side of the array; ignored☛ 0.
[Row_Val]: Optional. Value(s) to use for new rows in row format (across columns); ignored☛ empty string.
[Col_Val]: Optional. Value(s) to use for new columns in column format (down rows); ignored☛ empty string.

Excel Formula:
=LAMBDA(Array,[Num_Top],[Num_Bottom],[Num_Left],[Num_Right],[Row_Val],[Col_Val],
      LET(Arr, IFBLANK(Array, ""),          nTop, MAX(IFERROR(--(Num_Top),)),          nBot, MAX(IFERROR(--(Num_Bottom),)),
             nLef, MAX(IFERROR(--(Num_Left),)),          nRig, MAX(IFERROR(--(Num_Right),)),
             RowCt, CELLCOUNT(Arr, 1),          RowSum, nTop+nBot,          ColCt, CELLCOUNT(Arr, 2),          ColSum, nLef+nRig,
             NumScan, OR(RowSum<=-RowCt,  ColSum<=-ColCt),          NumMSG, "Remove less rows/columns",
             RowSeq, SEQUENCE(RowCt+RowSum),          ColSeq, SEQUENCE(, ColCt+ColSum),          Val, INDEX(Arr, RowSeq-nTop, ColSeq-nLef),
             RowVal, ACONSTANT(Row_Val, RowSeq, ColSeq),          ColVal, ACONSTANT(Col_Val, RowSeq, ColSeq),
             RowScan, (RowSeq<=nTop)+(RowSeq>RowCt+nTop),          ColScan, (ColSeq<=nLef)+(ColSeq>ColCt+nLef),
             Result, IFS(ColScan, ColVal,  RowScan, RowVal,  1, Val),          Return, IF(NumScan, NumMSG,  Result),
             Return
      )
  )
LAMBDA Examples.xlsx
ABCDEFGHIJKLMN
1ARESIZE
2
3Sample DataNum_Top:1Result
4AppleWatermelonPineappleNum_Bottom: FruitFruitFruit
5BananaAppleNum_Left:1AppleWatermelonPineapple
6#N/APearGrapeNum_Right:BananaApple
7PineappleBananaPearRow_Val:Fruit#N/APearGrape
8Col_Val:PineappleBananaPear
9
101 row is added to the top and 0 rows are added to the bottom.
111 column is added to the left and 0 columns are added to the right.
12The new row value is a single repeated value.
13The new column value is an empty string.
14=ARESIZE(B4:D7, G3,, G5,, G7)
15
ARESIZE
Cell Formulas
RangeFormula
J4:M8J4=ARESIZE(B4:D7, G3,, G5,, G7)
B14B14=FORMULATEXT(J4)
Dynamic array formulas.
 

Forum statistics

Threads
1,224,836
Messages
6,181,251
Members
453,027
Latest member
Lost_in_spreadsheets

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