![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Location: Carole
Posts: 8
|
I want to number rows in my spreadsheet. How can I get the rows numbered, to appear automatically. Then if I instert a row it alters the numbering accodingly?
|
|
|
|
|
|
#2 |
|
New Member
Join Date: Mar 2002
Location: Australia
Posts: 43
|
Probably the easiest way is to use the ROW worksheet function, and then add or subtract a fixed number to get where you want. For example, if you wanted to start your numbers at row 10 with the number 1 you'd put the following in cell A10:
=ROW(A10)-9 Then copy this formula down until you have as many rows/numbers as you want. Penfold |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Huntington Beach, CA USA
Posts: 327
|
Hi Carole,
If you want to do it with a Commandbutton try this: Private Sub CommandButton_Click() Dim ColA As Range, rw As Range, n% Set ColA = Range("A6") Set rw As = ColA.EntireRow Do Until Application.WorksheetFunction.CountA _ (rw) = 0 n = n + 1 ColA.Value = n Set ColA = ColA.Offset(1, 0) Set rw = rw.Offset(1, 0) Loop End Sub The above code starts the numbering sequence in Col A, Row 6 You can modify as needed James |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|