Lookup function
Excel ROWS function
ROWS returns how many rows a range or array has. It does not look at what is in the cells, so blanks count too. That makes it the right tool for sizing things: numbering a list, counting the rows a FILTER returned, or pointing INDEX at the last row.
=ROWS(array)Arguments
array- A range such as A2:A8, an array constant, or a formula that returns an array, such as FILTER(...).
ROWS examples
Every result below was calculated from this sample sheet by the same spreadsheet engine the Cellwise app uses.
| A | B | C | |
|---|---|---|---|
| 1 | Product | Category | Stock |
| 2 | Desk lamp | Lighting | 14 |
| 3 | Monitor arm | Desk | 3 |
| 4 | Cable tray | Desk | 0 |
| 5 | Floor lamp | Lighting | 8 |
| 6 | Footrest | Seating | 5 |
| 7 | Seat cushion | Seating | 22 |
| 8 | LED strip | Lighting | 2 |
Download this sheet as an Excel practice file (.xlsx)
Result: 7
There are 7 products. Unlike COUNTA, ROWS would still say 7 if some cells were empty.
Result: 1
An auto number: in row 2 this returns 1. Fill it down and the range grows by one row each time, so you get 1, 2, 3... and deleting a row renumbers the rest.
Result: 3
Counts the products FILTER returns, here the 3 with fewer than 5 in stock. It needs Excel 365 or 2021; FILTER returns #CALC! when nothing matches.
Result: LED strip
The last product in the list, LED strip: ROWS gives the position of the last row for INDEX.
How to use ROWS
- Click the cell for the result.
- Type =ROWS( and select the range, or type a formula that returns an array.
- Close the bracket and press Enter.
- For numbering, lock the first cell only ($A$2:A2) and fill down.
Common ROWS mistakes
Mixing up ROWS and ROW
ROW(A5) returns the row number, 5. ROWS(A2:A5) returns how many rows the range has, 4.
Counting entries with ROWS
ROWS counts rows, filled or not. To count cells that hold something use COUNTA; to count numbers use COUNT.
Locking both ends of a numbering range
$A$2:$A$2 never grows, so every row shows 1. Lock only the start: $A$2:A2.
ROWS FAQ
How do I count the number of rows in Excel?
For a range, =ROWS(A2:A100). For rows that actually have data, =COUNTA(A2:A100). The status bar also shows a count when you select cells.
How do I count the rows returned by FILTER?
Wrap it in ROWS: =ROWS(FILTER(A2:A8,C2:C8<5)). Add IFERROR around it if FILTER might find nothing, since FILTER returns #CALC! then.
What is the difference between ROWS and COLUMNS?
ROWS counts the rows in a range and COLUMNS counts the columns. =ROWS(A1:C5) is 5 and =COLUMNS(A1:C5) is 3.
Guides that use ROWS
- How to fix the #CALC! error in Excel
- How to calculate a moving average in Excel
- How to find missing numbers in a sequence in Excel
- How to combine multiple columns into one column in Excel
- How to convert one column into multiple columns in Excel
- How to find the longest streak in Excel
- How to create a habit tracker in Excel
Related functions
COLUMNSNumber of columns in a rangeROWRow number of a cellCOUNTACounts non-empty cellsINDEXValue at a position
Updated