Return specific columns from an array
=CHOOSECOLS(array, col_num1, [col_num2], ...)
| Parameter | Description |
|---|---|
array |
The array to extract columns from. |
col_num1 |
The numeric index of the first column to return. |
col_num2 |
[optional] The numeric index of the second column to return. |
To get columns 1 and 3 from an array, you can use CHOOSECOLS like this:
=CHOOSECOLS(A1:C5,1,3) // columns 1 and 3
To get the same two columns in reverse order:
=CHOOSECOLS(A1:C5,3,1) // columns 3 and 1
CHOOSECOLS will return a #VALUE! error if a requested column number is out of range:
=CHOOSECOLS(A1:C5,4) // returns #VALUE!
Another option for specifying which columns to return is to use an array constant like {1,2,3} as the second argument (col_num1). In the example below
=CHOOSECOLS(B3:F9,{1,3,5})
A nice feature of CHOOSECOLS is that you can use negative column numbers to extract columns from the end of a range. For example, to get the last colu
=CHOOSECOLS(range,-1)
To get the second-to-last column, you can use:
=CHOOSECOLS(range,-2)