View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default how to insert serial numbers to rows?

Here's one method I use to auto-number entries in a table. Removing
rows will cause the remaining rows to automatically renumber, adjusting
for rows that are added/removed...

Select cell A2
Open the Define Names dialog;

In the Name box type: '<sheetname'!LastCell
..where you substitute the actual sheetname for <sheetname;

In the RefersTo box enter =A1
Click the OK button to close the dialog

In cell A2 enter 1
In all the cells below enter =LastCell+1

If you want the cells to display a format then use Custom on the Number
Format tab of the Format Cells dialog.


Another way:
If you don't want to use a defined name then you can use the Row()
function as follows...

Scenario is Row1 has headers, data starts in Row2

In A2 type =Row()-1

Optionally, you just need to minus the row number immediately above the
first row of data if the start row isn't Row2. So.., if data starts in
Row6 then the formula to auto-number the data is...

=Row()-5

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion