How to create number sequence based on criteria in Excel?
In Excel, it may be a common task for you to make a number sequence for a list of cells. But, the task will get a little complicated if you need to create number sequence based on criteria. in this article, I will talk about some useful formulas for creating a number sequence based on criteria in Excel.
For example, I want to insert serial numbers based on the country column. That means, if there are multiple entries of the same country, I will order them accordingly as below screenshot shown:
To create serial numbers based on the duplicate values in another column, the COUNTIF function can do you a favor:
Step1: Enter the below formula into a blank cell where you want to insert the sequence number:
Step2: Then, drag the fill handle down to fill this formula to other cells, see screenshot:
If you want to create a number sequence based on a specific value in another column, for example, to create a list of serial numbers based on the specific text “Total” in column A: If a Total is displayed, skip that row and move to the next row continuing numbering.
To create this type of sequence, please use the following formula:
Step1: Enter the number 1 into the first cell where you want to insert the number sequence, see screenshot:
Step2: In the second cell, please enter either of the following formulas according to your Excel version:
=IF($A$2:$A$14="Total","",COUNTIF($C$2:C2,">0")+1) (Other Excel versions)
Note: In the above formulas, $A$2:$A$14="Total" is the range that includes the criteria you want to insert number sequence based on, C2 is the cell with the number 1 you entered in step1, please change them to your actual cell references.
Step3: Then, drag the fill handle to cell C14 for filling the range of cells with the serial numbers. See screenshot:
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!