ROWS function
Counts the number of rows in a range or array.
Available in All versions of Excel, including Microsoft 365, Excel for the web and Excel for Mac
In every Excel versionWorks in Google Sheets
Syntax
ROWS(array)| Argument | What it means | |
|---|---|---|
array | Required | A range, array constant, or formula that returns an array (such as FILTER or UNIQUE). |
Returns: A whole number: how many rows tall array is.
How ROWS works
ROWS measures how tall a range or array is. =ROWS(A2:C5) returns 4, whether the cells are full or empty. It is the vertical counterpart of COLUMNS.
In modern Excel ROWS has become a favourite companion of dynamic-array functions: wrap it around FILTER to count how many records meet a condition, or around UNIQUE to count distinct values. Because it measures the result's size, it counts everything the inner formula returns - including the single #CALC! or fallback row a FILTER returns when nothing matches, so handle that case separately.
Examples
1Number of products in a range
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Code | Product | Price | ||
| 2 | P-101 | Keyboard | 25 | 4 | |
| 3 | P-102 | Mouse | 12 | ||
| 4 | P-103 | Monitor | 149 | ||
| 5 | P-104 | Webcam | 39 |
Result: 4
The range covers rows 2 to 5: four products.
2Count distinct departments
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Emp ID | Name | Department | ||
| 2 | 1001 | Maria Lopez | Sales | 3 | |
| 3 | 1002 | Tom Becker | Finance | ||
| 4 | 1003 | Aisha Khan | IT | ||
| 5 | 1004 | Luca Rossi | Sales |
Result: 3
UNIQUE returns Sales, Finance and IT (Sales appears twice in the data), and ROWS counts them.
3Count matching records
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Rep | Region | Product | Units | Revenue | ||
| 2 | Ana | North | Laptop | 4 | 3600 | 3 | |
| 3 | Ben | South | Monitor | 10 | 1490 | ||
| 4 | Chloe | North | Monitor | 6 | 894 | ||
| 5 | Ana | East | Laptop | 2 | 1800 | ||
| 6 | Dev | South | Laptop | 5 | 4500 | ||
| 7 | Ben | East | Mouse | 30 | 360 | ||
| 8 | Chloe | North | Mouse | 12 | 144 |
Result: 3
FILTER returns the three North rows and ROWS counts them.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#CALC! | The inner FILTER found nothing and has no if_empty value. | Use =IFERROR(ROWS(FILTER(...)), 0) or COUNTIFS for simple counts. |
Tips
=ROWS($A$2:A2)copied down produces a running count 1, 2, 3...- To count only non-blank cells use COUNTA; ROWS counts blanks too.
Google Sheets
ROWS also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
ROWS in other languages
In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.
| Language | Function name |
|---|---|
| Czech | ŘÁDKY |
| Danish | RÆKKER |
| Dutch | RIJEN |
| Finnish | RIVIT |
| French | LIGNES |
| German | ZEILEN |
| Hungarian | SOROK |
| Italian | RIGHE |
| Norwegian (Bokmål) | RADER |
| Polish | ILE.WIERSZY |
| Portuguese (Brazil) | LINS |
| Portuguese (Portugal) | LINS |
| Russian | ЧСТРОК |
| Spanish | FILAS |
| Swedish | RADER |
| Turkish | SATIRSAY |
Recipes that use ROWS
- How to count distinct values with criteria in Excel
- How to count unique values in Excel
- How to list the top 5 values with names in Excel
- How to pick a random sample from a list in Excel
- How to return multiple matches in Excel
- How to reverse a list in Excel
- How to transpose rows and columns in Excel
- How to unpivot data in Excel with Power Query