Returns the specified rows from an array.
Syntax
=CHOOSEROWS(array,row_num1,[row_num2],…)
The CHOOSEROWS function syntax has the following arguments:
-
array The array containing the columns to be returned in the new array. Required.
-
row_num1 The first row number to be returned. Required.
-
[row_num2] Additional row numbers to be returned. Optional.
Errors
Excel returns a #VALUE error if the absolute value of any of the row_num arguments is zero or exceeds the number of rows in the array.
Examples
Copy the example data in the following table and paste it in cell A1 of a new Excel worksheet. If you need to, you can adjust the column widths to see all the data.
Returns an array of rows 1, 3, 5, and 1 again from the array in the range A2:B7.
Data |
|||
1 |
2 |
||
3 |
4 |
||
5 |
6 |
||
7 |
8 |
||
9 |
10 |
||
11 |
12 |
||
Formulas |
|||
=CHOOSEROWS(A2:B7,1,3,5,1) |
Returns an array of rows 1, 3, 5, and 1 again from the array in the range A2:B7 using array constants.
Data |
|||
1 |
2 |
||
3 |
4 |
||
5 |
6 |
||
7 |
8 |
||
9 |
10 |
||
11 |
12 |
||
Formulas |
|||
=CHOOSEROWS(A2:B7,{1,3},5,1) |
Returns an array of the last two rows from the array in the range A2:B7 in the order of row four and then row three.
Data |
|||
1 |
2 |
||
3 |
4 |
||
5 |
6 |
||
7 |
8 |
||
9 |
10 |
||
11 |
12 |
||
Formulas |
|||
=CHOOSEROWS(A2:B7,-1,-2) |