Going Stellar

Home/Google Sheets reference

Google Sheets function · Lookup

ROWS in Google Sheets: syntax and examples

ROWS counts the rows of a range or array and ignores what is inside. It is the usual way to size a table, to count what FILTER or UNIQUE returned, or to know how many records a table holds.

Syntax

ROWS(range)

Arguments

ArgumentTypeRequiredWhat it does
rangerangeyesThe range or array whose rows are counted.

Examples

The examples use this table, starting in A1:

ItemTeamQty
LampA5
ChairB0
StandA7
TrayB40
=ROWS(A1:C5)

Result: 5

The table has five rows, header included.

Run in a Google Sheet (English US locale) on .

=ROWS(A2:C5)

Result: 4

Data rows only, without the header.

Run in a Google Sheet (English US locale) on .

=ROWS({1; 2; 3})

Result: 3

A typed array: semicolons separate rows.

Run in a Google Sheet (English US locale) on .

=ROWS(FILTER(A2:C5, B2:B5="A"))

Result: 2

How many rows a FILTER returns: items from team A.

Run in a Google Sheet (English US locale) on .

=ROWS(UNIQUE(B2:B5))

Result: 2

The number of distinct teams.

Run in a Google Sheet (English US locale) on .

=ROWS(A2:C5) * COLUMNS(A2:C5)

Result: 12

Rows times columns: the number of cells in the block.

Run in a Google Sheet (English US locale) on .

Common errors

  • ROWS counts every row of the range, blank ones and the header included. ROWS(A1:C10) is 10 even if only five rows have data. Start the range under the header, as in A2:C5, to count records.
  • On a FILTER with no matches, ROWS returns #N/A and not 0. Wrap it in IFERROR to get 0.
  • It takes one argument. ROWS(A1:C5, A1:C5) and ROWS() both return #N/A.
  • For the number of filled cells use COUNTA instead. ROWS only measures the shape of the range.

Compared with Excel

Same syntax in Excel.

Sources

  1. ROWS (Docs Editors Help)

Markdown version · All functions