ROWS Function in Google Sheets: Count and Number Rows

ROWS returns the height of a range or array. It counts the rows you specify, including rows containing blank cells. Use it for range dimensions rather than counting completed records.

ROWS function syntax

=ROWS(range)
  • range: a cell reference, rectangular range or array whose height you need.
  • A single cell has one row. Columns do not affect the row count.

Set up the example data

Enter this dataset starting in A1. The first row contains headings. Keep the result area separate from the source table.

ProductQ1Q2
Pens1012
Pads8
Files59
Clips76

Count the rows in a list

Enter this formula in A8. A2:A5 contains four rows, so the result is 4. A blank product cell would not change the size of that range.

=ROWS(A2:A5)

Result: 4.

Count the rows in a list in Google Sheets, with the formula and its result visible.

Count a two-dimensional range

The table is four rows tall and three columns wide. ROWS returns only the height. Use COLUMNS when you need its width instead.

=ROWS(A2:C5)

Result: 4.

Create a running row number

Enter this beside the first record and fill down. The fixed starting reference stays A2 while the ending reference advances, giving 1, 2, 3 and 4.

=ROWS($A$2:A2)

Result: 1.

Number the entire fixed range

SEQUENCE uses the range height to return four row numbers vertically. Leave four destination cells empty. Blank records inside the range still receive a number.

=SEQUENCE(ROWS(A2:A5))

Result: 1; 2; 3; 4.

Get the last value in a specified range

INDEX uses ROWS to choose the final row of C2:C5, returning 6. This finds the last position in the range, not necessarily the last nonblank value.

=INDEX(C2:C5,ROWS(C2:C5))

Result: 6.

Count a filtered result

FILTER keeps Q2 values greater than 8, leaving Pens and Files. ROWS reports two returned records. This differs from manually hiding rows in the original range.

=ROWS(FILTER(A2:C5,C2:C5>8))

Result: 2.

Other Google Sheets articles you may also like