How to Add Automatic Serial Number with Formula in Excel

We will use a dataset that contains information about the Marks of some students. We will add automatic serial numbers to the dataset using some formulas.


Method 1 – Apply a Simple Formula to Add Automatic Serial Numbers in Excel

STEPS:

  • Type 1 in Cell B5.

Apply Simple Formula to Add Automatic Serial Number in Excel

  • Select Cell B6 and insert the formula below:
=B5+1

Apply Simple Formula to Add Automatic Serial Number in Excel

We are adding 1 to the previous cell value to get the serial numbers automatically. That’s why we need the first entry to be done manually.

  • Press Enter and drag the Fill Handle down.

Apply Simple Formula to Add Automatic Serial Number in Excel

  • You will see serial numbers like the below picture.

Apply Simple Formula to Add Automatic Serial Number in Excel


Method 2 – Adding Automatic Serial Numbers with the ROW Function

STEPS:

  • Select Cell B5 and use the formula below:
=ROW()-ROW($B$4)

Add Automatic Serial Number with Excel ROW Function

In this formula, we have used the ROW function. If you type =ROW() in Cell B5, the output will be 5 because it indicates the 5th row. The output of ROW($B$4) will always be 4 because we have used absolute cell reference here. That is why we have subtracted ROW($B$4) from ROW().

  • Hit Enter and drag down the Fill Handle.

Add Automatic Serial Number with Excel ROW Function

  • You will see the automatic serial numbers in the dataset.

Add Automatic Serial Number with Excel ROW Function


Method 3 – Using the Name Manager to Add Automatic Serial Numbers in Excel

STEPS:

  • Go to the Formulas tab and select Define Name. It will open the New Name dialog box.

Use Name Manager to Add Automatic Serial Number in Excel

  • In the New Name dialog box, add a name. We have named the range as Serial.
  • Use the formula below in the Refers to box:
=INDIRECT(“R[-1]C”,FALSE)

Use Name Manager to Add Automatic Serial Number in Excel

Here, we have used the INDIRECT function. The INDIRECT function returns the cell reference of a given text string. The first output of this formula is 0. It indicates the previous cell.

  • Select Cell B5 and type the formula below:
=SUM(Serial,1)

Use Name Manager to Add Automatic Serial Number in Excel

In this formula, we have used the SUM function. It sums up the value of the Serial function and 1. In the first case, the output is 1. Now, if you apply the formula in Cell B8, then, the formula will act like =SUM($B$7,1). That means it will sum up the value of Cell B7 with 1 and show it in Cell B8.

  • Hit Enter and drag the Fill Handle down.

Use Name Manager to Add Automatic Serial Number in Excel

  • You will see automatic serial numbers like the below picture.

Use Name Manager to Add Automatic Serial Number in Excel

Read More: How to Auto Generate Number Sequence in Excel


Method 4 – Using the COUNTA Function to Generate Automatic Serial Numbers

STEPS:

  • Use the formula below in Cell B5:
=COUNTA($C$5:C5)

Insert Excel Formula with COUNTA Function to Generate Automatic Serial Number

In this formula, we have used the COUNTA function to count the number of cells in the range $C$5:C5. This count will give us the serial numbers automatically. In Cell B6, the formula will change into =COUNTA($C$5:C6), which sees two values.

  • Press Enter and drag the Fill Handle down.

Insert Excel Formula with COUNTA Function to Generate Automatic Serial Number

  • You will be able to see the automatic serial numbers.

Insert Excel Formula with COUNTA Function to Generate Automatic Serial Number


Method 5 – Creating Automatic Serial Numbers in Excel with the SUBTOTAL Function

STEPS:

  • Select Cell B5 and use the formula below:
=SUBTOTAL(3,$C$5:C5)

Create Automatic Serial Number in Excel Using SUBTOTAL Function

In this formula, we have used the SUBTOTAL function. The first argument indicates the function number. And function number 3 refers to the COUNTA function. So, it will count the cells in the range $C$5:C5.

  • Press Enter and drag down the Fill Handle.

Create Automatic Serial Number in Excel Using SUBTOTAL Function

  • The dataset will look like the picture below.

Create Automatic Serial Number in Excel Using SUBTOTAL Function


Method 6 – Applying the SEQUENCE Function to Add Automatic Serial Numbers with Formula in Excel

The SEQUENCE function is available in Microsoft 365.

STEPS:

  • Select Cell B5 and use the following formula:
=SEQUENCE(COUNTA(C5:C14))

Apply SEQUENCE Function to Get Automatic Serial Number in Excel

In this formula, the output of COUNTA(C5:C14) is 10. So, the formula becomes =SEQUENCE(10) after the operation of the COUNTA function. The SEQUENCE function generates a sequential list from 1 to 10.

  • Hit Enter to see the results like the picture below.

Apply SEQUENCE Function to Get Automatic Serial Number in Excel


Method 7 – Combining IF and ROW Functions to Add Automatic Serial Numbers in Excel

We will add a name in Column C and the serial number will be visible automatically in Column B.

Combine Excel IF and ROW Functions to Add Automatic Serial Number

STEPS:

  • Select Cell B5 and use this formula:
=IF(C5="","",ROW()-ROW($B$4))

Combine Excel IF and ROW Functions to Add Automatic Serial Number

In this formula, we have used the ROW function inside the IF function. The formula will check if Cell C5 is empty or not. If Cell C5 is empty, the output of the formula will also be empty. Otherwise, it will show the value of ROW()-ROW($B$4). In the case of Cell B5, the value of ROW()-ROW($B$4) is 1.

  • Drag down the Fill Handle to copy the formula in the range B6:B10.

Combine Excel IF and ROW Functions to Add Automatic Serial Number

  • If you type a name in Cell C5, you will see the serial in Cell B5.

Combine Excel IF and ROW Functions to Add Automatic Serial Number

  • Type a name in Cell C6 and C7, respectively, and you will get the serial numbers automatically.

Combine Excel IF and ROW Functions to Add Automatic Serial Number

  • Insert all values to get the serial numbers.

Combine Excel IF and ROW Functions to Add Automatic Serial Number

Read More: Auto Serial Number in Excel Based on Another Column


Method 8 – Using the OFFSET Function to Create Automatic Serial Numbers

STEPS:

  • Insert an empty row into the dataset to avoid errors. Here, Row 5 is the added empty row.

Use Excel OFFSET Function to Create Automatic Serial Number

  • Select Cell B6 and insert the following formula:
=OFFSET(B6,-1,0)+1

Use Excel OFFSET Function to Create Automatic Serial Number

In this formula, the first argument of the OFFSET function is Cell B6. The second argument is -1 which indicates the previous row. And the third argument is 0 which refers to the same column. So, the output of OFFSET(B6,-1,0) is 0 since the Cell B5 is empty. The output of the formula is 1 for Cell B6.

  • Hit Enter and drag down the Fill Handle to copy the formula.

  • The dataset will look like the picture below.

Read More: Auto Numbering in Excel After Row Insert


Method 9 – Adding Roman Numbers as Automatic Serial Numbers

STEPS:

  • Select Cell B5 and insert the following:
=ROMAN(ROW()-ROW($B$4))

This formula is quite similar to that of Method 2. We inserted the formula of Method 2 inside the ROMAN function.

  • Press Enter and drag the Fill Handle down.

  • Here’s the result.


Method 10 – Adding Dynamic Serial Numbers in Excel with the Filter Option

STEPS:

  • Select Cell B5 and use the formula below:
=SUBTOTAL(3,C$5:C5)

In this formula, we have used the absolute cell reference for the row index only.

  • Hit Enter and drag down the Fill Handle.

  • You’ll get the serial numbers.

  • Go to the Home tab and select Sort & Filter. A drop-down menu will appear.
  • Select Filter.

  • You will see the drop-down arrows in the headers.

  • Click on a drop-down arrow and apply the filter according to your preference. We have unchecked serial numbers 4, 5, and 6.
  • Click OK to proceed.

  • The filtered rows are hidden and the serial numbers are updated automatically.

Read More: Automatically Number Rows in Excel


Download the Practice Book


Related Articles


<< Go Back to Serial Number in Excel | Numbering in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Mursalin Ibne Salehin
Mursalin Ibne Salehin

Mursalin Ibne Salehin holds a BSc in Electrical and Electronics Engineering from Bangladesh University of Engineering and Technology. Over the past 2 years, he has actively contributed to the ExcelDemy project, where he authored over 150 articles. He has also led a team with content development works. Currently, he is working as a Reviewer in the ExcelDemy Project. He likes using and learning about Microsoft Office, especially Excel. He is interested in data analysis with Excel, machine learning,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo