CHOOSEROWS Function¶
The CHOOSEROWS function in Excel is used to return specified rows from an array or range. It allows you to select one or more rows by their index numbers and returns them in the order specified. This is particularly useful for rearranging row order, extracting specific rows, or duplicating rows within a dataset.
Key Features of CHOOSEROWS:¶
- Extracts specific rows from an array or range by index.
- Returns rows in any order you specify.
- Supports negative indices to count from the bottom.
- Can duplicate rows by specifying the same index multiple times.
- Works seamlessly with other dynamic array functions.
Syntax:¶
- array: The array or range from which to return rows.
- row_num1: The index of the first row to return. Use positive numbers to count from the top (1 = first row) or negative numbers to count from the bottom (-1 = last row).
- row_num2, … (optional): Additional row indices to return.
How CHOOSEROWS Works:¶
- Takes the input array and identifies the rows at each specified index.
- Positive indices count from the top (1 is the first row).
- Negative indices count from the bottom (-1 is the last row).
- Returns the selected rows in the order specified.
- If an index is out of range, Excel returns a
#VALUE!error.
Examples:¶
1. Extract a Single Row:¶
Given a range A1:D5 with data:
Result:
2. Extract Multiple Rows:¶
Result:
3. Reorder Rows:¶
Result:
4. Use Negative Indices:¶
Result:
5. Duplicate a Row:¶
Result:
6. Extract from an Array Constant:¶
Result:
(Returns the first and third rows of the array)
7. Combine with SORT:¶
Result:
8. Extract First and Last Rows:¶
Result:
9. Reverse Row Order:¶
Result:
Notes:¶
CHOOSEROWSis available in Excel 365 and Excel 2021 or later versions.- Row indices must be non-zero integers; 0 returns a
#VALUE!error. - If any row index exceeds the number of rows in the array, Excel returns a
#VALUE!error. - The function preserves all columns from the original array.
- Results automatically spill into adjacent cells.
Applications:¶
- Row Selection: Extract only the rows you need from a large dataset.
- Row Reordering: Rearrange rows without modifying the source data.
- Top/Bottom N: Select specific rows like first, last, or middle entries.
- Data Sampling: Pick specific rows for analysis or reporting.
- Row Duplication: Repeat rows for formatting or calculation purposes.
Related Functions:¶
- CHOOSECOLS: Returns specified columns from an array (column equivalent of CHOOSEROWS).
- DROP: Removes a specified number of rows or columns from an array.
- TAKE: Extracts a specified number of rows or columns from an array.
- INDEX: Returns a value or reference from a specific position in an array.
- VSTACK: Vertically combines arrays top to bottom.
- FILTER: Returns rows that meet specified criteria.
Tip: Combine
CHOOSEROWSwithCHOOSECOLSto extract a specific subset of both rows and columns from a dataset. For example,=CHOOSECOLS(CHOOSEROWS(data, 1, 2, 3), 1, 3)returns columns 1 and 3 from the first three rows.