Excel.Tips.Net ExcelTips (Menu Interface)

Automatically Numbering Rows

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Automatically Numbering Rows.

Libby wants to insert a row number into column A of her worksheet. She wants the column to reflect the correct number of the row, even when she adds or deletes rows.

There are any number of formulas you can use in column A that will return a row number. Perhaps the easiest is to use the ROW function, like this:


This formula returns the row number of the cell in which the formula appears. If you want to offset the row number returned (for instance, if you have some headers in rows 1 and 2 and you want cell A3 to return a row value of 1), then you can modify the formula to reflect the desired adjustment:


Of course, the ROW function isn't the only candidate for your formulas. You can also use a formula that actually examines the contents of the adjacent column (B) and return a row number only if there is something in that adjacent cell.


This formula, placed in cell A1, examines the contents of cell B1. If there is something there, then the COUNTA function is used to count the number of occupied cells between cell B1 and whatever cell is to the right of where this formula is placed. The formula also places a period after the row number that is returned. Make sure the dollar signs are included, as shown, and then copy the formula down as many cells as necessary to create your row numbers.

The advantage to a formula such as this one is that it checks to see if something is in column B before it returns a row number. This means that you can copy the formula down beyond the actual end of your data rows, and only those rows that have data (triggered by something in column B) will have a row number. The same sort of technique could be used with the ROW function instead of the COUNTA function:


ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2911) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Automatically Numbering Rows.

Related Tips:

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!


Leave your own comment:

  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*What is 4+5 (To prevent automated submissions and spam.)
          Commenting Terms

Comments for this tip:

Rezwan    27 Nov 2015, 21:52
how can i serial my number from excel sheet..
Michael (Micky) Avidan    16 Oct 2015, 05:22
In cell A1 type the following formula and copy down as far as needed.

Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)
Michael (Micky) Avidan    16 Oct 2015, 05:19
@adonis abocatal jr.,
NOT up to cell A50.
Copy it right to cell AA1
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)
Michael (Micky) Avidan    16 Oct 2015, 05:17
@adonis abocatal jr.,
I'm not sure I fully understood your request but in the mean while try this - in cell C1 type the hereunder suggested formula and copy along row 1 up to cell A50.

=IF(COLUMN()-3+$A1>$B1,"", COLUMN()-3+$A1)
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)

Michael (Micky) Avidan    16 Oct 2015, 05:10
In cell A1 type: =INT((ROW()-1)/10)+1 and copy down as far as needed.
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)
lipsa    15 Oct 2015, 05:09
i want below ouput:

please help me by using formula
Mayur Patel    16 Sep 2015, 10:37
I wish to enter more than 100 numbers in a column, but when I change any number in between,the following number does not change.

adonis abocatal jr    07 Sep 2015, 12:46
please help me if how can i generate serial no.

in cell A value is 1
in cell B value is 5

i want to generate serial number
in cell C=1 D=2 E=3 F=4 G=5

adonis abocatal jr    07 Sep 2015, 12:40
hi i need a formula for below ex:
A B C D E F G H I J & SO ON...
 1 10 10 1 2 3 4 5 6 7 8 9 10
 11 15 4 11 12 13 14 15

value in A B if i enter qty in cell c

will generate serial no. to D & So on..
Sibin    31 Aug 2015, 07:57

Is there any formula available for generating numbers where for ten cells the number should be constant.


cell number I need
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 2
12 2
13 2
14 2
15 2
16 2
17 2
18 2
19 2
20 2
21 3
22 3
Michael (Micky) Avidan    11 Mar 2015, 06:40
In cell A1 type a "legal" date.
In cell A2 type: =EDATE(A1,1)
Now, copy cell A2 down up to A24.
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
Pete Davenport    10 Mar 2015, 15:26
How do I create a column containing dates starting with 20150305 or March 05 2015 and continuing for say 2 years, with a dated row created on the 5th of each month.
Jason    09 Mar 2015, 17:19
Carol Doden    14 Jan 2015, 13:15
Thank you for telling me how to print my row numbers. It was fast and easy! Thank you very mch. I used =row()-1 in Cell A2 and it works.

Thank you very much.
Michael (Micky) Avidan    09 Jan 2015, 05:27
"Be careful".
What will happen when she will run the Find & Replace over a column which has:
614614 and 615614 ?
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
Willy Vanhaelen    08 Jan 2015, 09:45
Another way is to use Find and Replace.
- Select the cells you want to change
- Press Ctrl+H
- enter 614 in de 'Find What:'
- enter 615 in 'Replace with:'
- click Replace All
Michael (Micky) Avidan    08 Jan 2015, 06:08
The fastest way - without any helper column and/or VBA Programming will be:
* in cell A3 change (type) the new number: 615000
* In A4 type: 615001
* Select both(!) cells > click & hold(!) the lower right corner of cell A4 (the fill handle) and drag down until the last cell you want to fill the sequential numbers and release the mouse.
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
Amber    07 Jan 2015, 15:21
In column A cell #3 I have a number of 614000 then #4 is 614001 #5 is 614002 and so on and so on. I want to change the 3rd number which is the 4 in 614000 to a 5 all the way down. How do I do this?
Cindy Kirsten    06 Mar 2013, 15:59
Thanks for posting this solution - it was just what I needed!
gerald diamond    26 Nov 2012, 12:11
The trouble with this formula


is that, while it will not number rows that have only a space in the b cell, it will count them.

Thus your numbering may not be consecutive.

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us


Advertise with Us

Our Privacy Policy

Our Sites


Beauty and Style




DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)



Home Improvement

Money and Finances


Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives


Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2015 Sharon Parq Associates, Inc.