Cellwise Start free

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.

ABC
1ProductCategoryStock
2Desk lampLighting14
3Monitor armDesk3
4Cable trayDesk0
5Floor lampLighting8
6FootrestSeating5
7Seat cushionSeating22
8LED stripLighting2

Download this sheet as an Excel practice file (.xlsx)

  1. =ROWS(A2:A8)

    Result: 7

    There are 7 products. Unlike COUNTA, ROWS would still say 7 if some cells were empty.

  2. =ROWS($A$2:A2)

    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.

  3. =ROWS(FILTER(A2:A8,C2:C8<5))

    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.

  4. =INDEX(A2:A8,ROWS(A2:A8))

    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

  1. Click the cell for the result.
  2. Type =ROWS( and select the range, or type a formula that returns an array.
  3. Close the bracket and press Enter.
  4. 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

Related functions

Updated