Dynamic arrays function
ROWS function in Google Sheets and Excel
ROWS returns how many rows a range, array or formula result has, whether the cells are full or empty.
Checked against Microsoft's and Google's documentation on · Example calculated on a live sheet
- Excel 2016
- Excel 2019
- Excel 2021
- Excel 2024
- Microsoft 365
- Google Sheets
Syntax
ROWS(array)Arguments in [brackets] are optional. Google Sheets writes it ROWS(range).
Example
=ROWS(A2:A9) reads: Count the rows in A2:A9, the column of reps.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Rep | Region | Jul | Aug | Sep | Target | 8 | |
| 2 | Amara Osei | North | $12,400 | $13,100 | $11,800 | $36,000 | ||
| 3 | Ben Fischer | South | $9,800 | $10,250 | $12,100 | $30,000 | ||
| 4 | Lina Chen | East | $15,200 | $14,800 | $16,900 | $45,000 | ||
| 5 | Diego Alvarez | West | $8,700 | $9,100 | $8,400 | $28,000 | ||
| 6 | Eva Novak | North | $11,200 | $12,600 | $13,900 | $36,000 | ||
| 7 | Farid Haddad | South | $13,300 | $12,900 | $14,100 | $39,000 | ||
| 8 | Grace Kim | East | $10,100 | $9,600 | $10,800 | $33,000 | ||
| 9 | Hugo Martin | West | $14,500 | $15,800 | $15,100 | $42,000 |
H1 shows 8: A2:A9 has eight rows.
How the spreadsheet calculates it
Counts the rows in A2:A9.
- 1. ROWS: Counts the rows in
A2:A9.range=`A2:A9`: a range or a result, like a FILTER
More ROWS examples
=ROWS(FILTER(A2:A9,B2:B9="North"))How many reps are in the North region: 2.=ROWS($A$2:A2)A running number that counts 1, 2, 3 as you fill down.=INDEX(A2:A9,ROWS(A2:A9))The last rep in the list.=ROWS(UNIQUE(B2:B9))How many different regions there are.
Paste any of these into the formula explainer to see it step by step.
Tips
- Use
ROWS($A$2:A2)for numbering that survives inserted rows above the list. - Pair it with INDEX for the last item:
INDEX(A2:A9,ROWS(A2:A9)). - Its partner
COLUMNScounts columns the same way.
What ROWS is used for
Counting the results of FILTER or UNIQUE, running numbers that don't depend on where a list starts, finding the last item of a range with INDEX, and dividing by the number of rows in averages and shares.
Arguments
| Argument | Required | What it is |
|---|---|---|
| array | Yes | A range like A2:A9, an array constant, or a formula that returns an array, such as FILTER. |
Common mistakes
Expecting ROWS to count only filled cells: it counts every row of the range.
Confusing it with
ROW: ROW gives the row number of a cell, ROWS gives how many rows a range has.Counting FILTER matches when nothing matches: FILTER returns #CALC!, so ROWS does too. Give FILTER an if_empty value or use COUNTIFS instead.
In Google Sheets
Google Sheets has ROWS(range) with the same argument, and it works on ranges and on arrays returned by formulas like FILTER.
Errors you may see with ROWS
Questions
How do I count the results of a FILTER?
Wrap ROWS around it: ROWS(FILTER(A2:A9,B2:B9="North")) is 2 on this sheet. See the FILTER guide.
What's the difference between ROWS and COUNTA?
ROWS counts every row of the range, empty or not; COUNTA counts only the cells that aren't empty. ROWS(A2:A100) is always 99.
How do I number rows with ROWS?
Use a range that grows as you fill down: ROWS($A$2:A2) gives 1, then 2, 3 and so on, whichever row the list starts on.
What's the difference between ROW and ROWS?
ROW(A5) returns 5, the row number of that cell on the sheet. ROWS(A5:A9) returns 5 too, but because the range is five rows tall. ROW tells you where a cell is; ROWS tells you how big a range is, which is why ROWS keeps working when the list moves.
Sources
Official documentation the facts on this page were checked against.