Auto numbering

k0915

New Member
Joined
Jan 7, 2014
Messages
3
I would like to have auto-numbering after inserting new row, required that the new row has input any text.

here is the example:

Item no. name
1    Mary
2    Tom
3    Jack
4    Peter
5    John

When I insert new row, I would like to have the row no. only when the column "name" has some text inside, otherwise the auto-numbering will skip the blank row.

Item no. name
1    Mary
2    Tom

3    Jack
4    Peter
5    John

Item no. name
1    Mary
2    Tom
3    Susan
4    Jack
5    Peter
6    John

Would there be any code to do this?
Thank you very much!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Assumming your numbers are in Column A, starting in Row 1, instead of putting 2 below the 1, put = A1+1.
Then drag that formula down. (or click back on the cell, then double click the bottom right hand corner of the active cell)
When you add a row. Click on the empty spot and press (control + D), and it should repopulate the numbers to the correct order.
 
Upvote 0
Thanks for your reply.

However, I would like to have the row number appears automatically only if i put some text in the cell under the column "name" of the row, and if possible, I would like to have it automatically instead of repopulate the numbers by any steps.
 
Upvote 0
If you don't mind doing a bit of work, a formula will suffice for the basic calculation:

=IF(LEN(B2),COUNTA($B$2:B2),"")

...you'll just need to copy it into the new row(s) you insert.
 
Upvote 0
Nice one Paddy. K0915 was wanting it to autopopulate when a row was inserted. While your formula would produce a similar result, it would still require the formula to be copied down after the insert...or have I got it wrong?

K0915, if you go to the links that I provided it should explain how to write the macro. If you're not proficient in writing macros, I highly recommend using either Paddy's or My formula and copying it down when you insert a new row.
 
Upvote 0

Forum statistics

Threads
1,217,448
Messages
6,136,688
Members
450,024
Latest member
Beagle263

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top