looking for a more powerful way to number rows

Plasmech

New Member
Joined
Oct 26, 2021
Messages
44
Office Version
  1. 365
Platform
  1. Windows
In almost all of my spreadsheets, my first column is an line number / index number column. I code this as such:

A1 1
A2 =A1+1
A3 =A2+1
A4 =A3+1
A5 =A4+1
A6 =A5+1

But this is not a very powerful or forward-looking way to do it, however.

If I delete the 4th row, for example, rows 5 and 6 will return #REF!.

...and if I move a row, the numbers will no longer be sequential.

There must be a better way to do this, something embarrassingly obvious that I'm missing.

Any suggestions?

Thanks.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I don't quite understand the criteria, but this will give you the row index of a cell:
Excel Formula:
=ROW()
 
Upvote 0
I'm late to the party here, but since you are using MS 365 you could generate sequential row numbers by entering a simple formula and allowing it to spill down. The numbers will remain unchanged by row deletions or, say, cutting a cell or cells. In the example below, the first 100 cells in col A are numbered sequentially from 1-100 when the formula in A1 is entered.
Book1.xlsm
A
11
Sheet2
Cell Formulas
RangeFormula
A1:A100A1=SEQUENCE(100,1,1,1)
Dynamic array formulas.
 
Upvote 0
A2 = =OFFSET(A2,-1,0)+1

Getting back to this (sorry for the delay), it does not work on the first row. It works on the 2nd (and subsequent) row, as long as there's a 1 in the first row. Maybe I am doing something wrong?

Thanks.
 
Upvote 0
Well, the offset function is trying to look at the cell above. If you have this in cell A1, it's trying to reference a non-existent cell. You could try this
Cell A1: =IFERROR(OFFSET(A1,-1,0),0)+1
 
Upvote 0
Well, the offset function is trying to look at the cell above. If you have this in cell A1, it's trying to reference a non-existent cell. You could try this
Cell A1: =IFERROR(OFFSET(A1,-1,0),0)+1

I am getting this:
 

Attachments

  • Excel_line_no_test.png
    Excel_line_no_test.png
    18.7 KB · Views: 7
Upvote 0
The formula you are showing for Cell A4 should be: =IFERROR(OFFSET(A4,-1,0),0)+1

I can't see the formula you have in Cell A5
 
Upvote 0
That gives me a #VALUE! in A4. The rest of the column is fill-down.
 
Upvote 0

Forum statistics

Threads
1,215,035
Messages
6,122,785
Members
449,095
Latest member
m_smith_solihull

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