keepcalculator

06 Numbers and Powers

Total Rows in Range: Excel Count Methods

Card No. 06·48916 · Updated · Standard formula, shown below

Total rows in range 10 rows
Number of rows
10
You entered
You enter
Number of rows
You get
Total rows in range
Rounding
0 dp

This page answers the question “Total rows in range?” directly: the total number of rows in a range is simply the count of horizontal bands in that range, regardless of whether cells contain data or are empty. In Excel, you can get this number instantly by selecting the range and reading the row count from the Name Box, or by using the ROWS function. Below, we explain every practical method, the difference between used rows and total rows, and common pitfalls.

Formula

The core formula is trivial: Total rows in range = ROWS(range). In Excel, the ROWS function returns the count of rows in a given reference. For example, =ROWS(A1:A10) returns 10. If you are working with a named range like SalesData, =ROWS(SalesData) gives the row count. The formula counts every row in the rectangular block, including blank rows, hidden rows, and rows with no formatting.

For a range that spans multiple areas (e.g., (A1:A5,C1:C3)), ROWS returns the total of all areas: 5 + 3 = 8. The ROWS function ignores any filtering or hiding; it always returns the full row count of the reference.

Worked Example

Using the default values from the calculator above: you enter 10 rows. The calculator outputs 10 as the total rows. This matches =ROWS(A1:A10) in Excel. If you had a range like B2:D100, the row count would be 99 (from row 2 to row 100 inclusive). The calculator here simply takes your input number and displays it as the total, because the total rows in a range is exactly the number you specify when you define the range.

How to Count Rows in Excel: 5 Methods

  • Name Box method: Click in the Name Box (left of the formula bar), type the range (e.g., A1:C50), press Enter. The Name Box shows the range, but not the count. To see the count, select the range with your mouse – the Name Box displays “50R x 3C” when you drag select.
  • ROWS function: In any cell, type =ROWS(A1:C50) – returns 50.
  • Status bar: Select the entire range with the mouse or keyboard (Shift+Arrow). The status bar at the bottom shows “Count: 50” if you have numeric cells, but for row count you need the Name Box trick or the ROWS function.
  • Go To Special: Press F5 > Special > Last cell. This moves to the last used cell. The row number of that cell is the last row of the used range, but not necessarily the total rows if you have blank rows below.
  • VBA: In a module, Range("A1:C50").Rows.Count returns 50. This is useful for macros.

Total Rows vs. Used Rows vs. Selected Rows

A common confusion: “total rows in range” can mean three different things. The total rows in a range is the number of rows in the rectangular block you specify – e.g., A1:C50 has 50 rows. The used rows (or last used row) is the row number of the bottom-most cell that contains data or formatting. For example, if you have data in A1:A10 and you accidentally formatted A100, the used range is 100 rows, even though only 10 have data. The selected rows is what you highlight at the moment; it may be a subset of the range.

To find the last used row in a column, you can use =COUNTA(A:A) which counts non-empty cells, but that gives the number of data rows, not the row index. For the row index of the last non-empty cell, use =MAX(ROW(A:A)*(A:A<>"")) entered as an array formula (Ctrl+Shift+Enter in older Excel). This returns the row number of the last data entry.

How to Choose the Right Method

  • If you need a static number for a formula, use ROWS.
  • If you need to know how many rows are actually filled with data, use COUNTA on a specific column (but beware of blank cells in that column).
  • If you need the row count of a filtered list, use SUBTOTAL(3, range) for visible cells only.
  • If you need the row count of a table (Excel Table), use Table1.Rows.Count in VBA, or =ROWS(Table1) – but note that Table1 includes the header row, so data rows = ROWS(Table1)-1.

Common Problems and Mistakes

  • Counting blank rows: ROWS counts blank rows. If you want only non-blank rows, use COUNTA on a column that always has data.
  • Hidden rows: ROWS includes hidden rows. If you filter data, ROWS still returns the full count. Use SUBTOTAL(3, range) for visible rows.
  • Entire column reference: =ROWS(A:A) returns 1,048,576 (the total rows in a worksheet). This is rarely what you want. Use a specific range like A1:A100.
  • Off-by-one errors: If your data starts at row 2 and ends at row 100, the total rows are 99, not 100. Use =ROWS(A2:A100) which correctly returns 99.
  • Merged cells: Merged cells can cause confusion because ROWS still counts each row individually, but data may appear to span multiple rows.

Rows in Google Sheets and Other Tools

Google Sheets has the same ROWS function. The syntax and behavior are identical. In LibreOffice Calc, the function is also ROWS. In Python/pandas, the equivalent is df.shape[0] for the number of rows in a DataFrame. In SQL, COUNT(*) gives the number of rows in a table, but that counts data rows, not the capacity of the range.

For a spreadsheet range, the total rows is a property of the reference, not the data. So the answer to “Total rows in range?” is always the number of row bands in that reference, regardless of content.

Frequently Asked Questions

Does ROWS count hidden rows?

Yes, ROWS counts all rows in the range, including hidden rows and rows filtered out. It is purely a geometric count of the reference. If you need to count only visible rows after filtering, use SUBTOTAL(3, range) or AGGREGATE(3,5,range).

What is the difference between ROWS and COUNTA?

ROWS returns the number of rows in a range, regardless of content. COUNTA returns the number of non-empty cells in a range. For example, =ROWS(A1:A10) returns 10, while =COUNTA(A1:A10) returns the count of cells that contain any value (text, number, error) – blank cells are ignored.

How do I count rows in a range that has blank cells?

If you need the total row count, use ROWS – it includes blanks. If you need the number of rows with at least one data point, you can use =SUMPRODUCT((A1:A100<>"")*1) for a single column, but that counts cells, not rows. To count rows where column A is non-empty, use =COUNTA(A1:A100). For rows where any column has data, use =SUMPRODUCT((A1:A100<>"")+(B1:B100<>"")>0).

Why does my range show 1,048,576 rows when I select a whole column?

That is the maximum number of rows in an Excel worksheet (as of Excel 2007 and later). When you reference an entire column like A:A, ROWS returns 1,048,576. To avoid this, always use a specific range like A1:A1000 or a table with defined bounds.

Can I count rows in a named range?

Yes. If you have a named range called MyData, simply use =ROWS(MyData). This works for named ranges, table names, and even ranges on other sheets (e.g., =ROWS(Sheet2!A1:B10)).

Does the ROWS function include the header row?

Yes, ROWS includes every row in the reference, including header rows. If you have an Excel Table with a header row, =ROWS(Table1) returns the number of rows including the header. To get data rows only, subtract 1: =ROWS(Table1)-1.

Related

Formula used
in r | Number of rows | - | 10 | 1 | 1048576
out total | Total rows in range | rows | r | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →