1. Home
  2. Functions
  3. Array
  4. ARRAY_CONSTRAIN

ARRAY_CONSTRAIN function

Returns the top left part of an array with at most the given number of rows and columns.

Syntax

=ARRAY_CONSTRAIN(input_range, num_rows, num_cols)

Arguments

ArgumentRequiredDescription
input_rangeRequiredThe range or array
num_rowsRequiredMaximum rows
num_colsRequiredMaximum 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 1 by 2 array
Spilled result
AB
112
=ARRAY_CONSTRAIN({1,2;3,4}, 5, 1)Result 2 by 1 array
Spilled result
A
11
23

Every formula, right in your browser

SheetsBat calculates 536 functions, with charts, pivot tables and live collaboration. Free to start.