What is the ROWS function?
=ROWS(array)ROWS counts how many rows a range has. It looks only at the size of the range, not whether cells are empty.
ROW and ROWS look alike, but ROW is a position and ROWS is a count.
ROWS only counts the rows in a range, but copied down it produces 1, 2, 3…, which makes it the usual way to feed the "k-th" argument of SMALL, LARGE or INDEX. Delete a row and the numbers close up on their own.
Arguments
- array
- The range whose rows you count.
ROWS examples
Example 1. Number of rows
=ROWS(B2:D6)Rows 2 to 6, so 5.
Example 2. Running number
=ROWS($A$2:A2)Copy down for 1, 2, 3….
Example 3. List scores from low to high
=SMALL($B$2:$D$6, ROWS($A$1:A1))Copied down, ROWS gives 1, 2, 3, so the 1st, 2nd and 3rd smallest scores appear in order.
Copied to ROWS($A$1:A1) Result 1st row 1 76 2nd row 2 78 3rd row 3 84 Example 4. Value in the last row
=INDEX(A2:A10, ROWS(A2:A10))Returns the last cell of the range (A10) without editing the formula when the range grows.
Common mistakes
Expecting a count of filled cells
Empty cells count too. For filled cells use COUNTA.
Confusing it with ROW
ROW(B2:D6) is the first row number, 2; ROWS(B2:D6) is 5.
Where the $ goes
Without $ at the start of ROWS($A$1:A1), the whole range moves when copied and the number stays 1.
FAQ
- Number of columns?
- Use COLUMNS.
- Total number of cells?
- =ROWS(range)*COLUMNS(range).
- The last row that has data?
- Count filled cells with COUNTA instead of ROWS.