Syntax
=ARRAY_CONSTRAIN(input_range, num_rows, num_cols)Arguments
| Argument | Required | Description |
|---|---|---|
input_range | Required | The range or array |
num_rows | Required | Maximum rows |
num_cols | Required | Maximum columns |
How to use ARRAY_CONSTRAIN
When ARRAY_CONSTRAIN returns more than one value, the result spills into the cells below and to the right. Keep those cells empty, or you get #SPILL!.
ARRAY_CONSTRAIN takes 3 required arguments. Type =ARRAY_CONSTRAIN( in a cell and SheetsBat shows the arguments as you go. Optional arguments are shown in square brackets; leave them out to use their default.
Examples
Each result below was calculated by the SheetsBat formula engine.
=ARRAY_CONSTRAIN({1,2,3;4,5,6}, 1, 2)Result Spilled result
| A | B | |
|---|---|---|
| 1 | 1 | 2 |
=ARRAY_CONSTRAIN({1,2;3,4}, 5, 1)Result Spilled result
| A | |
|---|---|
| 1 | 1 |
| 2 | 3 |
Related array functions
- ARRAYFORMULAReturns the result of a formula that works on whole ranges, so it can spill.
- BYCOLApplies a LAMBDA to each column of an array and returns one result per column.
- BYROWApplies a LAMBDA to each row of an array and returns one result per row.
- CHOOSECOLSReturns the given columns of an array (negative numbers count from the end).
- CHOOSEROWSReturns the given rows of an array (negative numbers count from the end).
- DROPRemoves a number of rows or columns from the start (positive) or end (negative) of an array.
- EXPANDExpands an array to the given number of rows and columns, filling new cells with a pad value.
- FILTERReturns the rows (or columns) of a range or array that meet a condition.
- FLATTENPuts the values of one or more ranges into a single column, reading row by row.