ROWS Function¶
The ROWS function in Excel is used to return the number of rows in a reference or array. It counts the total number of rows regardless of content, including empty cells.
Key Features of ROWS:¶
- Returns the count of rows in a range, array, or reference.
- Works with cell references, named ranges, and array constants.
- Counts all rows including those with empty cells.
- Useful for dynamic formulas that need to know the size of a data range.
- Often used with other functions like INDEX, INDIRECT, and OFFSET.
Syntax:¶
- array: A reference, array constant, or range for which you want the number of rows.
How ROWS Works:¶
- The function receives a reference or array as input.
- It counts the total number of rows in the specified range or array.
- Returns a single number representing the row count.
- Empty cells within the range are still counted as part of a row.
Examples:¶
1. Count Rows in a Range:¶
Result:
2. Count Rows in a Multi-Column Range:¶
Result:
3. Count Rows in an Array Constant:¶
Result:
4. Use with Named Range:¶
Result:
5. Combine with COLUMNS for Array Dimensions:¶
Result:
6. Dynamic Last Row Calculation:¶
Result:
7. Use with SEQUENCE to Create Row Numbers:¶
Result:
8. Calculate Average per Row:¶
Result:
Notes:¶
ROWSis available in all versions of Excel.- The function returns a single numeric value, not an array.
- If the array argument is a reference to a closed workbook,
ROWSreturns a#REF!error. - For array constants, use semicolons (
;) to separate rows and commas (,) to separate columns. ROWScounts the physical rows in the reference, not the number of non-empty rows.
Applications:¶
- Dynamic Formulas: Create formulas that automatically adjust based on data range size.
- Data Validation: Verify that imported data has the expected number of rows.
- Loop Alternatives: Use with other functions to process data without VBA loops.
- Report Building: Calculate statistics like averages per row or total row counts.
- Array Sizing: Determine dimensions of arrays for use with other dynamic array functions.
Related Functions:¶
- COLUMN: Returns the column number of a reference.
- COLUMNS: Returns the number of columns in a reference or array.
- ROW: Returns the row number of a reference.
- COUNTA: Counts non-empty cells in a range.
- COUNT: Counts cells containing numbers in a range.
- INDEX: Returns a value at a given position in a range or array.
- OFFSET: Returns a reference offset from a starting point.
- INDIRECT: Returns a reference specified by a text string.
- CHOOSEROWS: Returns specified rows from an array.
Tip: Combine
ROWSwithCOLUMNSto get the full dimensions of a range. For example,=ROWS(A1:D10) * COLUMNS(A1:D10)returns the total number of cells (40) in the range.