To number lines in Excel, enter =ROW()-1 in the first numbering cell below a header in row 1, then copy the formula down. For a fixed list, you can also use the fill handle or Excel’s Series command; Microsoft 365 and Excel 2021 users can create a run of numbers with =SEQUENCE(10). Choose a method based on whether the numbering should stay fixed or adjust when rows change.
What You’ll Need
- An Excel workbook with the list or worksheet you want to number.
- A blank column beside your data if you want numbers next to individual records. Avoid placing a formula where it would overwrite existing information.
- For the SEQUENCE method, Excel for Microsoft 365 or Excel 2021 or later. The fill-handle, Series, and ROW methods work in many earlier desktop versions too.
Step-by-Step
- Choose where the numbers should go. If you are numbering records, insert or identify an empty column beside them and give it a clear heading such as Number or ID. If you are numbering worksheet lines generally, you can use a blank column at the left or right of the data. Decide whether every row should receive a number, including rows with no data, or whether only populated records should be numbered. This choice affects which method is most suitable.
- Use the fill handle for a quick fixed sequence. Type
1in the first cell and2in the cell directly below it. Select both cells. Move the pointer to the small square at the lower-right corner of the selection, called the fill handle, and drag it down to the last row you need. Excel recognizes the step between the first two values and continues 3, 4, 5, and so on. If you drag from only one cell containing 1, Excel may copy 1 repeatedly; selecting both starter numbers tells Excel to continue the pattern. This creates values rather than a formula-based relationship, so the numbers will not automatically renumber if you add or remove records later. - Fill a longer fixed series with the Series command. Enter
1in the first cell where numbering should begin. Select that cell and the remaining blank cells you want to number. On the Windows ribbon, choose Home > Fill > Series. In the dialog, select Columns if the selection runs downward, choose Linear, set Step value to 1, and enter the final number in Stop value. Select OK. For example, a selection of 100 cells with a starting value of 1, step 1, and stop value 100 receives numbers 1 through 100. If the numbering runs across columns instead, choose Rows. This method is handy for a long range when dragging the fill handle would be awkward. - Use a ROW formula when numbers should follow worksheet positions. With a header in row 1 and the first record in row 2, enter this formula in A2:
=ROW()-1. It returns 1 in A2 because the row number is 2 and 2 minus 1 is 1. Copy the formula down using the fill handle, or select the range below and use Home > Fill > Down. In Windows Excel, Ctrl+D fills the selected range from its top cell; on Mac, use the ribbon command if the shortcut differs for your keyboard setup. The next row returns 2, the following row returns 3, and so on. If the header is in row 4 and the first data row is 5, put=ROW()-ROW($A$4)in A5 instead; it returns 1 there and increases by one per row. Adjust the header reference if your layout is different. - Use SEQUENCE to create a spill of numbers. In a clear cell with ten empty cells below it, enter
=SEQUENCE(10). In Excel for Microsoft 365 or Excel 2021 and later, Excel fills the cells below with 1 through 10 automatically. The result is a dynamic array, so you only enter the formula once. To create a different count, replace 10 with the number of lines needed. You can also specify a starting value and step: with a clear destination area,=SEQUENCE(10,1,1,1)creates ten rows, one column, starting at 1 and increasing by 1. SEQUENCE is not available in some older Excel versions; use the fill handle or Series command there. Leave the spill area empty, because existing content in any required result cell prevents the formula from filling the range. - Number only rows that contain a record, if needed. If column B contains the record names and A is the numbering column, enter
=IF(B2="","",COUNTA($B$2:B2))in A2 and copy it down. This leaves A blank when the corresponding B cell is blank and counts populated cells from the first record through the current row. For example, if B2 contains Alice, B3 is empty, B4 contains Chen, and B5 contains Dina, the results in A2:A5 are 1, blank, 2, and 3. This is useful when a list has intentional gaps, but make sure the chosen record column is consistently filled for every record. If that column is empty for a real record, the count will not represent the full list. - Check what happens when you sort or filter. If you sort a list, select the entire table or data range, including the number column, so each number stays with its record. A ROW formula bases its result on the record’s current worksheet position, so its displayed number may change after sorting; static numbers generally move with their rows when the entire range is sorted together. Filtering hides rows but does not normally renumber a standard ROW formula to show only visible records. If you need visible records to count from 1 after filtering, place this formula in A2 beside nonblank record names in B2:B100, then copy it down:
=SUBTOTAL(3,$B$2:B2). It counts visible, nonempty cells in the expanding range, so filtered-out records are skipped. Use a reliably populated column for the count. Check the result after applying or changing a filter.
Common Mistakes
- Dragging a single 1 and getting repeated 1s. Excel often copies a single value instead of inferring a sequence. Start with both 1 and 2, select both, and then drag, or use the Series dialog.
- Using the wrong row offset in a formula.
=ROW()-1is correct when the first numbered row is row 2. If the first record is on a different row, the first result may not be 1. Subtract the row above the first record, or use the adjusted formula shown in the steps. - Numbering a whole worksheet row when you mean to number records. Worksheet row numbers at the far left are built into Excel and cannot be replaced with custom sequence labels. Add a separate column for record numbers instead.
- Sorting only part of the data. Sorting the number column without the corresponding names or details disconnects numbers from their records. Select the complete range or use an Excel table so the fields are kept together.
- Overwriting existing cells with a spill formula. SEQUENCE needs an unobstructed result area. Clear the intended spill cells or put the formula somewhere else before entering it.
- Expecting fixed numbers to update automatically. Values made with the fill handle or Series are static. They do not renumber themselves when a row is inserted or deleted. Use formulas if numbering should respond to worksheet position.
Tips
- Pick the method that matches the job. Use typed values or Series for a one-time, fixed list. Use ROW formulas for row-based numbering that should update when records move. Use SEQUENCE when you want a quick dynamic block of consecutive numbers and have room for its results.
- Use a table for growing lists. Select your data and choose Insert > Table, or press Ctrl+T on Windows. A table helps keep records together when sorting and filtering. When you add a new row, Excel usually extends formulas in a calculated column, but check that the numbering behaves the way you intend.
- Keep identifiers separate from row positions. A row number is a useful display label, but it can change after a sort or deletion. If a number must remain a permanent identifier for a record, use a fixed value or a separately managed ID rather than relying on a ROW formula.
- Fill down only as far as necessary. Excess formulas in thousands of empty rows can make a sheet harder to use and may make blank-looking cells part of the used range. Copy the formula to the actual data rows, then extend it when the list grows.
- Confirm the final number. For a continuous list starting at 1, the last number should equal the number of numbered records. If it does not, look for blank records, skipped rows, a misplaced formula, or a selection that stopped too soon.
Troubleshooting
The formula appears as text instead of calculating. Check whether the cell is formatted as Text. Change its format to General using Home > Number Format, then edit the cell and press Enter. Also check that the entry starts with an equals sign and that Show Formulas is not turned on. On Windows, Ctrl+` toggles formula display; the key combination can vary on Mac, so use the Formulas tab’s Show Formulas control if needed.
Every row shows the same number. If you used the fill handle, start again with two seed values, 1 and 2. If you used a formula, inspect the copied cells to confirm the reference changes as expected. A formula with a fixed row reference, or values copied from one cell, will not create a rising sequence.
The numbering starts at 0 or another unexpected value. Check the row containing the first formula and the subtraction in the formula. For example, =ROW()-1 returns 1 only in row 2. If your first record is in row 6, the formula must subtract 5 to return 1 there; an adjusted row-reference formula is less error-prone when the header position may change.
SEQUENCE returns a spill error or does not fill down. Make sure every cell where the results should appear is empty, including cells that look blank but contain spaces or formulas. Remove merged cells from the intended spill range, too. If your Excel edition does not support dynamic arrays, use the fill handle or Series command instead.
Numbers do not match the visible filtered rows. A normal ROW formula counts worksheet positions, not just visible records. For a visible-only count, use the SUBTOTAL approach from the steps and ensure the referenced data column has no blanks for valid records. If you inserted a filter after copying the formula, recalculate or check that calculation is set to Automatic under Formulas > Calculation Options.
Frequently Asked Questions
Can Excel number rows automatically when I add new data?
Yes. A ROW formula copied into a table’s numbering column can often extend when a new table row is added. SEQUENCE can also produce a dynamic array when its input is designed to change, but the simple =SEQUENCE(10) example always creates ten numbers. For a growing table, verify that new rows inherit the formula and that the result matches your numbering rules.
How do I number lines without skipping blank rows?
Use a row-based formula such as =ROW()-1 when the first numbered row is row 2, and fill it through the entire range. It numbers each worksheet row whether or not the row contains data. If blank rows should remain unnumbered, use the conditional formula based on a consistently filled data column instead.
Can I restart numbering in a new section?
Yes. Enter the first number for each section manually, then use the fill handle or Series command to continue within that section. A simple ROW formula continues counting worksheet rows, so it will not restart by itself at a heading. For a straightforward report, separate formulas or manually entered starting points are often easiest to maintain.
How do I number only visible rows after filtering?
Use =SUBTOTAL(3,$B$2:B2) in the first numbering cell beside a consistently populated column B, then fill down. The count excludes rows hidden by a filter and updates as the filter changes. A standard ROW formula does not do this; it continues to reflect physical row positions.
Does Excel already number worksheet lines?
Yes. The gray row headings along the left side show worksheet row numbers, and Excel also displays column letters across the top. Those built-in labels are not the same as a numbered list column: they are worksheet coordinates, can change as rows are inserted, and are not normally part of printed data. Add a separate numbering column when the numbers need to appear with your records.
Related
- How to Insert a Check Mark in Excel in 4 Easy Ways
- How to Insert an Image in an Excel Cell and Keep It in Place
- How to Insert a Background Image in Excel for a Worksheet
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- How to Get Rid of a Page Split in ExcelTo remove a page split in Excel, first identify what you are seeing: for a print-page boundary, go…
- Create a Cursive Signature in Outlook: Step-by-StepTo create a cursive signature in Outlook, add either script-style text or a picture of your handwritten signature…
- How to Create a Booklet in Microsoft WordTo create a booklet in Microsoft Word, open the desktop app, go to Layout > Margins > Custom…
- How to Freeze Panes in Excel: Keep Rows and Columns VisibleTo keep headings or identifying columns visible while you scroll in Excel for Microsoft 365 on Windows, select…
- Excel Box Plot Explained: Create and Read OneAn Excel box plot, also called a box-and-whisker chart, summarizes how a set of numbers is distributed: its…
- Excel Day Counter: Count Days Between DatesWith a start date in A2 and an end date in B2, enter =B2-A2 to count the days…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.