Subtotal Formula in Excel for Serial Number: 3 Suitable Methods

Method 1 – Use of SUBTOTAL Function for Serial Number

Steps:

  • Select Cell B5 and type the formula below.

=SUBTOTAL(3,$C$5:C5)

  • Press Enter.

Subtotal Formula in Excel for Serial Number

  • Drag the Fill Handle icon to fill the other cells with the above formula.
  • Get the following serial number.

  • See that no new serial is created for the cells with no corresponding values for the related cells if we drag the Fill Handle icon into the next few cells.

Subtotal Formula in Excel for Serial Number

  • Filter the data to show the only visible column serial number in the dataset.
  • Select the range of cells and press Ctrl+Shift+L.

  • Add a filter to the data, as shown below.

Subtotal Formula in Excel for Serial Number

  • Click on the Math column drop-down icon, select Number Filters, and finally select Greater Than option.

  • The Custom AutoFilter window appears, type your required number in the is greater than a box.
  • Click OK.

Subtotal Formula in Excel for Serial Number

Use of SUBTOTAL Function for Serial number

 


Method 2 – Combining SUBTOTAL with IF Function

Steps:

  • Select Cell B5 and type the formula below.

=IF(C5="","",SUBTOTAL(3,$C$5:C5))

  • Press Enter.

Subtotal Formula in Excel for Serial Number

  • Drag the Fill Handle icon to fill the other cells with the above formula.
  • Get the following serial number.

  • Filter the data to show the only column serial number in the dataset.
  • Select the range of cells and press Ctrl+Shift+L.

Subtotal Formula in Excel for Serial Number

  • Add a filter to the data, as shown below.

  • Click on the Math column drop-down icon, select Number Filters, and finally select Greater Than option.

Subtotal Formula in Excel for Serial Number

  • The Custom AutoFilter window appears, type your required number in the is greater than box.
  • Click OK.

  • Filter the Math column data based on a score greater than 80. The serial number is automatically generated when the column is reduced according to the criteria.

Combining SUBTOTAL with IF Function

 How Does the Formula Work?

  • SUBTOTAL(3,$C$5:C5)

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

  • IF(C5=””,””,SUBTOTAL(3,$C$5:C5))

If Cell C5 is empty, the IF function will return blank; otherwise, it will return the SUBTOTAL function value.


Method 3 – Applying MAX and SUBTOTAL Functions

Steps:

  • Select Cell B5 and type the formula below.

=MAX(SUBTOTAL(3,D$5:D5))

  • Press Enter.

Subtotal Formula in Excel for Serial Number

  • Drag the Fill Handle icon to fill the other cells with the above formula.
  • Get the following serial number.

  • No new serial is created for the cells where there are no corresponding values for the related cells if we drag the Fill Handle icon into the next few cells.

Subtotal Formula in Excel for Serial Number

  • Filter the data to show the only column serial number in the dataset.
  • Select the range of cells and press Ctrl+Shift+L.

  • Add a filter to the data, as shown below.

Subtotal Formula in Excel for Serial Number

  • Click on the Math column drop-down icon, select Number Filters, and finally select Greater Than option.

  • When the Custom AutoFilter window appears, type your required number in the is greater than box.
  • Click OK.

Subtotal Formula in Excel for Serial Number

  • Get the following column when you filter the Math column data based on a score greater than 70. The serial number is automatically generated when the column is reduced according to the criteria.

Applying MAX and SUBTOTAL Functions

How Does the Formula Work?

  • SUBTOTAL(3,$C$5:C5)

We used the SUBTOTAL function. The first argument indicates the function number. And function number 3 refers to the COUNTA function. Count the cells in the range $C$5:C5.

  • MAX(SUBTOTAL(3,D$5:D5))

The MAX function will return the largest value in the list of arguments.


Things to Remember

When you are creating serial numbers using the subtotal formula, you need to keep certain things in mind.

✎ You should keep in mind that Excel doesn’t consider hidden values the same as the filtered-out values. So, when you hide any rows the serial will not generate automatically.

✎ When using multiple functions in one formula, you need to put the parenthesis carefully, otherwise, the formula will not be executed.


Download Practice Workbook

Download this practice workbook to exercise while you are reading this article. It contains all the datasets in different spreadsheets for a clear understanding. Try yourself while you go through the step-by-step process.


Get FREE Advanced Excel Exercises with Solutions!
Saquib Ahmad Shuvo
Saquib Ahmad Shuvo

Saquib Ahmad Bhuiyan, holding a BSc degree in Naval Architecture & Marine Engineering from Bangladesh University of Engineering and Technology, skillfully integrates engineering expertise with a passion for Excel. He provides solutions to complex issues as an Excel & VBA Content Developer for ExcelDemy Forum. He demonstrates an enthusiastic mindset and adeptness in managing critical situations with finesse, showcasing his commitment to excellence. Apart from creating Excel tutorials, he is interested in Data Analysis with MS Excel, Rhinoceros,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo