How to Count Lines in Excel: Rows, Blank Cells & More
In this article
The quickest way to see how many lines (rows) an Excel sheet contains is to press Ctrl+End (Windows) or Control+End (Mac) to jump to the last used cell, then read its row number. For a count of rows that contain data, use =COUNTA(A:A) on a column that is always filled. For the total number of rows in the entire worksheet, the fixed answer is 1,048,576 in modern Excel. Below are the exact steps for each method, plus how to count only visible rows, blank rows, and lines inside a single cell.
What You'll Need
- Excel for Microsoft 365, Excel 2021, 2019, or 2016 on Windows or Mac (the menus are nearly identical; labels can differ slightly by version and region).
- A workbook with data, or any blank workbook for testing.
- No add-ins or macros required.
Step-by-Step
Method 1: Jump to the last used cell (fastest visual check)
- Click any cell inside your data range.
- Press Ctrl+End on Windows or Control+End on Mac. Excel selects the last cell that has ever been used in the sheet.
- Look at the Name Box (the small box to the left of the formula bar). It shows something like F482. The number after the letter is your last used row, so this sheet has 482 lines of content.
- If the Name Box is not visible, go to View and tick Formula Bar in the Show group.
This method counts the last row Excel considers used, which can include rows that once had data and were cleared. If the number looks too high, see Common Mistakes below.
Method 2: Count non-empty cells in a column
- Pick a column that is filled on every data row (for example, an ID or date column).
- Click an empty cell outside your data.
- Type =COUNTA(A:A) and press Enter, replacing A with your column letter.
- The result is the number of non-blank cells in that column, which equals your line count if the column has no gaps.
If your data has a header row, subtract 1. To count only numeric entries (for example, invoice numbers), use =COUNT(A:A) instead; COUNT ignores text and blanks.
Method 3: Count rows in a specific range
- Select the range you care about, such as A2:C500.
- Look at the status bar at the bottom of the Excel window. It shows Count for the number of non-empty cells in the selection.
- If you need the row count rather than the cell count, use =ROWS(A2:C500) in an empty cell. That returns 499, the number of rows in the range.
Method 4: Count visible rows only (after filtering)
- Apply your filter with Data > Filter.
- In an empty cell, type =SUBTOTAL(103,A2:A1000), replacing the range with your data rows.
- Press Enter. The result updates as you change the filter, so it always shows the number of visible non-blank rows.
The 103 argument tells SUBTOTAL to count non-blank cells while ignoring hidden rows. Use 3 instead of 103 if you want to include manually hidden rows.
Method 5: Count lines inside one cell
- If a cell contains text separated by line breaks (Alt+Enter on Windows, Control+Option+Return on Mac), count the breaks with =LEN(A1)-LEN(SUBSTITUTE(A1,CHAR(10),""))+1.
- That formula returns the number of lines in cell A1, including wrapped text only if actual line breaks were inserted.
Method 6: Count blank rows in a range
- Use =ROWS(A2:A100)-COUNTA(A2:A100) to get the number of empty cells in that column range.
- To count fully blank rows across several columns, use =SUMPRODUCT(--(COUNTIF(OFFSET(A2:A100,ROW(A2:A100)-ROW(A2),0,1,3),"")=3)) style formulas, or simpler: add a helper column with =COUNTA(A2:C2) and count zeros.
Common Mistakes
- Trusting Ctrl+End after deleting data. Excel remembers the last used cell until you save, close, and reopen the file, or until you delete the entire rows and save. If the number looks inflated, select the rows below your data, right-click, choose Delete, then save.
- Using COUNTA on a column with gaps. A blank cell in the middle of your ID column makes COUNTA undercount. Pick a column that is always filled, or use =MAX(ROW(range)) logic instead.
- Forgetting the header. COUNTA includes the header row, so subtract 1 when reporting the number of data lines.
- Confusing rows with cells. The status bar Count shows selected cells, not rows. Three columns selected across 100 rows shows 300, not 100.
- Assuming every Excel file has 1,048,576 rows. Files saved in the legacy .xls format are limited to 65,536 rows. Save as .xlsx to get the modern limit.
Tips
- Press Ctrl+Down Arrow to jump to the last filled cell in a column; it stops at the first blank, which is handy for spotting gaps.
- Use Ctrl+Shift+End to select everything from the active cell to the last used cell, then read the row count in the status bar.
- Convert your range to a Table (Insert > Table) and the status bar will show a clean count of table rows when you select the table.
- Name Box navigation works in every modern Excel version and is the least error-prone quick check.
- If you need the count in a report, put the COUNTA formula on a separate summary sheet so filters and sorting do not disturb it.
Troubleshooting
- Ctrl+End jumps far past your data. Something below is formatted or was once filled. Select the empty rows, right-click, Delete, then save and reopen.
- COUNTA returns a number larger than expected. Check for stray spaces or formulas returning empty strings (""). COUNTA counts formula results even when they look blank. Use =COUNTIF(A:A,"?*") to count only text entries.
- SUBTOTAL does not change when filtering. Make sure you used 103, not 3, and that the filter is applied through Data > Filter rather than manual row hiding.
- Formula shows #NAME?. Check spelling and that you are using a comma or semicolon as the argument separator, depending on your region settings.
- Row limit seems lower than 1,048,576. The file is probably .xls. Use File > Save As and choose Excel Workbook (.xlsx).
Frequently Asked Questions
How many rows does an Excel worksheet have?
1,048,576 rows and 16,384 columns in .xlsx files. Legacy .xls files stop at 65,536 rows.
How do I count lines without a formula?
Press Ctrl+End and read the row number in the Name Box, or select your range and check the status bar.
Does COUNTA count hidden rows?
Yes. Use SUBTOTAL with 103 if you want hidden rows excluded.
How do I count rows that contain any text in any column?
Add a helper column with =COUNTA(A2:C2) and then sum or count the results above zero.
Why does Ctrl+End go past my last row of data?
Excel still treats those cells as used, usually because of leftover formatting. Delete the empty rows and save.