Auto Numbering

vijay2482

Board Regular
Joined
Mar 3, 2009
Messages
142
i have a worksheet with few rows..
in column B i want to number the rows from 1 to n...

how to achieve this???

thanks in advance
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
How far down do you want to number? To number column B until the last entry in column A:

Code:
Sub AutoNum()
 
Dim rngStart, rngC As Range
 
Set rngStart = Range(Cells(1, "B"), Cells(Cells(Rows.Count, "A").End(xlUp).Row, "B"))
 
Application.ScreenUpdating = False
 
For Each rngC In rngStart
    rngC.Value = rngC.Row
Next rngC
 
Application.ScreenUpdating = True
 
End Sub
 
Upvote 0
thanks...
your code works fine...
it enters the number of the row...

i want the numbers from 1 to n to be entered in column B starting from row 4

i did a small modification to ur code and got the result in column B line number starting from 4...

i want it to start at 1 in column B row 4

Code:
Sub AutoNum()
Dim rngStart, rngC As Range
Set rngStart = Range(Cells(4, "B"), Cells(Cells(Rows.Count, "A").End(xlUp).row, "B"))
Application.ScreenUpdating = False
For Each rngC In rngStart
    rngC.Value = rngC.row
Next rngC
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Rich (BB code):
Sub AutoNum()
Dim rngStart, rngC As Range
Set rngStart = Range(Cells(4, "B"), Cells(Cells(Rows.Count, "A").End(xlUp).row, "B"))
Application.ScreenUpdating = False
For Each rngC In rngStart
    rngC.Value = rngC.row-3
Next rngC
Application.ScreenUpdating = True
End Sub
 
Upvote 0
thanks a lot..............

that works perfect..
u r a genious

thank you once again for helping...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,645
Members
448,974
Latest member
DumbFinanceBro

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