Purpose
Return value
Syntax
=ROWS(array)
- array - A reference to a cell or range of cells.
How to use
The ROWS function returns the count of rows in a given reference as a number. For example, =ROWS(A1:A5) returns 5, since the range A1:A5 contains 5 rows. ROWS takes just one argument, called array, which can be a range or array.
Examples
Use the ROWS function to get the row count for a given reference or range. For example, there are 10 rows in the range A1:F10 so the formula below returns 10:
=ROWS(A1:F10) // returns 10
The range A1:Z100 contains 100 rows, so the formula below returns 100:
=ROWS(A1:Z100) // returns 100
You can also use the ROWS function to get a row count for an array constant:
=ROWS({1;2;3;4;5}) // returns 5
Although there is no built-in function to count the number of cells in a range, you can use the ROWS function together with the COLUMNS function like this:
=COLUMNS(range)*ROWS(range) // total cells
=COLUMNS(A1:Z100)*ROWS(A1:Z100) // returns 2600
This article explains this formula in more detail.
Notes
- Array can be a range or a reference to a single contiguous group of cells.
- Array can be an array constant or an array created by another formula.
- To count columns, see the COLUMNS function.
- To get row numbers, see the ROW function.
- To lookup a row number, see the MATCH function.
ROWS function examples
Combine ranges
Display sorted values with helper column
First column number in range
Randomly assign data to groups
Total rows in range
Random sort
Multiple matches into separate rows
Dynamic date list
Average last N values in a table
Random value from list or table
Get address of named range or table
Last row number in range
Address of last cell in range
Get relative row numbers in range
Last n rows
ROWS function videos
How to create a named range
How Excel Table ranges work
How to create a dynamic named range with a Table
How to perform a random sort
Introduction to structured references
How to count items in a filtered list
Formulas to query a table
How to remove an Excel Table
What is a dynamic named range
Related functions
ROW Function
The Excel ROW function returns the row number for a reference. For example, ROW(C5) returns 5, since C5 is the fifth row in the spreadsheet. When no reference is provided, ROW returns the row number of the cell which contains the formula.
COLUMN Function
The Excel COLUMN function returns the column number for a reference. For example, COLUMN(C5) returns 3, since C is the third column in the spreadsheet. When no reference is provided, COLUMN returns the column number of the cell which contains the formula.
COLUMNS Function
The Excel COLUMNS function returns the count of columns in a given reference. For example, COLUMNS(A1:C3) returns 3, since the range A1:C3 contains 3 columns.