To count lines in an Excel spreadsheet, the quickest reliable method is to select the range you care about and read the status bar at the bottom of the window, which shows a count of selected cells. For a true row count of data, use COUNTA on a single column (for example =COUNTA(A:A)) or press Ctrl+End (Windows) or Fn+Control+Right Arrow then Fn+Control+Down Arrow (Mac) to jump to the last used cell. The rest of this guide covers each method, plus the traps that make counts wrong.
What You'll Need
- Excel for Windows, Excel for Mac, or Excel for the web (labels and shortcuts differ slightly by version, device and region).
- A spreadsheet with data already entered.
- No add-ins or special permissions are required for the methods below.
Step-by-Step
- Decide what "line" means for your task. A line can mean a physical row on the sheet (all 1,048,576 of them), a row containing data, or a line of text inside a wrapped cell. Most people want rows that contain data, so use the methods below that count non-empty cells.
- Count selected cells with the status bar. Click the first cell in your range, hold Shift, and click the last cell. Look at the bottom of the Excel window: the status bar shows Count for the number of non-empty cells selected and Count plus a total when numbers are involved. If you only see one figure, right-click the status bar and tick Count and Numerical Count.
- Count rows of data with COUNTA. Click an empty cell and type
=COUNTA(A:A), replacing A with the column that is always filled in (an ID or name column works well). Press Enter. This returns the number of non-empty cells in that column, which equals your data rows when there are no blanks and no header. If row 1 is a header, subtract one:=COUNTA(A:A)-1. - Count rows with blanks in the key column. If your chosen column has gaps, count a column that is always populated, or use
=COUNTA(A2:A1000)with an explicit range instead of the whole column. Whole-column references include the header and any stray text far down the sheet. - Count only rows that meet a condition. Use
=COUNTIF(B:B,"Open")to count rows where column B equals a value, or=COUNTIFS(B:B,"Open",C:C,">0")for multiple conditions. This is the correct tool when "lines" means orders, tickets or entries of a certain type. - Find the last used row quickly. Press Ctrl+End on Windows or Fn+Control+Right Arrow then Fn+Control+Down Arrow on a Mac. Excel jumps to the last cell containing data or formatting. The row number shown in the Name Box (left of the formula bar) is your last used row.
- Count all rows on the sheet, including empty ones. Click any cell and press Ctrl+Down Arrow (Windows) or Fn+Control+Down Arrow (Mac) to jump to the bottom of the used range, or type a row number in the Name Box and press Enter to jump directly. The maximum row number is 1,048,576 in current Excel versions; that is the physical line count of every sheet.
- Count lines inside a single cell. If a cell contains wrapped or line-broken text, Excel has no built-in function that returns the number of line breaks. A practical workaround is to count characters with and without the line-break character:
=LEN(A1)-LEN(SUBSTITUTE(A1,CHAR(10),""))+1. This gives the number of visual lines in that cell. - Verify the result. Compare the formula result with the status-bar count for the same range. If they disagree, you have blanks, hidden rows, filtered rows or text stored as numbers affecting the count.
Common Mistakes
- Using COUNTA on a column with blanks. It counts non-empty cells only, so gaps make the total lower than the real number of rows.
- Forgetting the header row. Whole-column formulas include row 1, so subtract one when row 1 is a label.
- Confusing COUNT and COUNTA.
COUNTcounts numbers only; text entries are ignored. UseCOUNTAfor mixed data. - Assuming filtered rows are excluded. COUNTA and COUNTIF include hidden and filtered-out rows. Use
SUBTOTAL(103,range)if you need a count of only visible rows. - Trusting Ctrl+End after deleting data. Formatting left behind can make Excel jump far past your real data. Clear formatting in the empty rows below your table.
- Counting lines of wrapped text as rows. A wrapped cell is still one row; only the display changes.
Tips
- Convert your range to a table (Insert > Table) so formulas expand automatically as rows are added.
- Put the count formula on a separate summary sheet to keep your data sheet clean.
- Use the Name Box to jump to a specific row or range quickly; type
A1:A500and press Enter to select it. - Right-click the status bar to choose which statistics appear; this is the fastest way to check a count without writing a formula.
- For repeated counts, name the range (Formulas > Define Name) and reference the name in your formula.
Troubleshooting
- The count is higher than expected. Check for stray values, spaces or formatting far below your data. Select the empty rows beneath your table and delete them, then save.
- The count is lower than expected. Look for blank cells in the column you counted. Switch to a column that is always filled, or use an explicit range.
- The formula shows an error. Confirm the range reference is valid and that quotation marks around text criteria are straight quotes, not curly ones.
- Ctrl+End jumps too far. Delete unused rows and columns, then save and reopen the file. Formatting alone can extend the used range.
- The status bar shows no count. Right-click the status bar and enable Count; some views hide it by default.
- Counts differ between Excel for the web and desktop. Some functions and shortcuts behave differently; run the count in the desktop app if results must match.
Frequently Asked Questions
How do I count rows in Excel without a formula?
Select the range and read the Count figure on the status bar, or press Ctrl+End to jump to the last used cell and read its row number.
What is the difference between COUNT and COUNTA?
COUNT counts cells containing numbers. COUNTA counts any non-empty cell, including text and dates.
How do I count only visible rows after filtering?
Use =SUBTOTAL(103,A2:A1000). The 103 argument tells Excel to ignore hidden and filtered-out rows.
Can Excel count line breaks inside a cell?
Not directly. Use the LEN and SUBSTITUTE formula shown above with CHAR(10) to count line breaks.
How many rows does an Excel sheet have?
1,048,576 rows and 16,384 columns in current Excel versions. Older .xls files have fewer.
Why does COUNTA give a different number than my status bar?
The formula range and the selected range are probably different, or one includes blank cells. Select exactly the same cells to compare.