I am trying to add a serial number to the rows in an excel sheet. I have multiple duplicate values in "ID" column and I am hiding the duplicate values first and then trying to add the serial number only for the unique values. I want all the duplicate values to have same serial number as the original value.

My sheet looks like this now : Original sheet

It looks like this after hiding the duplicates: Duplicates hidden

What I am trying to achieve looks like this: Expected

There are more than 50K rows and I am hoping that there is some way to do this in excel without manually filling in the numbers in the "No." column. Any help would be greatly appreciated!

2

There are 2 best solutions below

5
Dominique On BEST ANSWER

This can be done with a simple formula:

=IF(B2=B3,A2,A2+1)

First put the value "1" in cell "A2". Then put the mentioned value below and continue dragging and dropping.

Your result will look as follows:

screenshot

0
VBasic2008 On

Add Sequential Serial Numbers

  • In cell A2 (adjust the last row):
=XMATCH(B2:B13,UNIQUE(B2:B13))

enter image description here