formulastreak

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

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.

Q3 sales team · edit H1 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultH1 = 8
ABCDEFGH
1RepRegionJulAugSepTarget8
2Amara OseiNorth$12,400$13,100$11,800$36,000
3Ben FischerSouth$9,800$10,250$12,100$30,000
4Lina ChenEast$15,200$14,800$16,900$45,000
5Diego AlvarezWest$8,700$9,100$8,400$28,000
6Eva NovakNorth$11,200$12,600$13,900$36,000
7Farid HaddadSouth$13,300$12,900$14,100$39,000
8Grace KimEast$10,100$9,600$10,800$33,000
9Hugo MartinWest$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. 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 COLUMNS counts 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

ArgumentRequiredWhat it is
arrayYesA 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

  • #CALC!: It counts a FILTER result that's empty.
  • #REF!: Rows the range pointed at were deleted, so the formula holds #REF! instead of a range.

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.

Practise ROWS on a live sheet

Lesson 38, FILTER (Unit 11, Dynamic arrays), has 7 graded exercises, checked instantly, with steps and hints when you're stuck. Pro