MS Excel: How to Autonumber in Excel This Excel tutorial explains how to create an autonumber (with screenshots and step-by-step instructions). Question: I need help in creating an autonumber (primary key) in Excel like the one in Access. It must automatically update when a row is added.
It must be able to stay unique if a row is inserted and must not change if a row is cut/pasted. Answer: To create an autonumber field in Excel, you have a few options - each with its own set of limitations. Option #1 To create an autonumber field, you could try using the row function. This function returns the current row number. The limitations of this option is that if you insert a new row, your row function will return a different value in the lines below the inserted line. So in this option, you will not be able to keep your primary key static if you are inserting new rows in the middle. Also, you insert a blank row, you'll need a way to fill in the formula.
Option #2 To create an autonumber field, you could try using the Offset function. In cell A1, enter the number 1. Then in cell A2, enter the formula: =OFFSET(A2,-1,0)+1 Then copy the formula from cell A2, down as far as you need.
Use an Excel formula to generate a number series. Put your cursor in the cell at A1. This means the block that is located where Column A meets Row 1. In A1, type =ROW(). This formula should generate the first number in your series. Select the fill handle on the bottom right of the A1 cell, and drag down or across to create the number series. Place the mouse pointer on the row number in the row header — the mouse pointer changes to a black arrow pointing to the right. Rows, and Cells in Excel. Here's How to Move Around and Between Worksheet Tabs in Excel. 10 Spreadsheet Terms Every Excel User Should Know.
The limitations of this option is that if you insert a new row, you will need to readjust all of your formulas (below the row inserted). So there is more maintenance involved than option #1.
Also, this option does not allow you to keep your primary key static if you are inserting new rows in the middle.