How to Assign Serial Number to Unique Values with Condition in Excel

rengifot

New Member
Joined
Jan 5, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I am trying to assign a unique serial number to column C if column A is the same therapeutic class and column b is a different drug so I am looking for a formula that can help me with this task. Column D is the end result, which I did manually. Thank you in advance for your assistance
THERAPEUTIC_CLASSDRUG_NAMEAssign Unique Serial NumberSequence
ACNE~ISOTRETINOINABSORICA
1​
ACNE~ISOTRETINOINABSORICA
1​
ACNE~ISOTRETINOINABSORICA
1​
ACNE~ISOTRETINOINABSORICA
1​
ACNE~ISOTRETINOINABSORICA
1​
ACNE~ISOTRETINOINABSORICA
1​
ACNE~ISOTRETINOINABSORICA
1​
ACNE~ISOTRETINOINABSORICA
1​
ACNE~ISOTRETINOINABSORICA
1​
ACNE~ISOTRETINOINABSORICA
1​
ACNE~TOPICALACZONE
1​
ACNE~TOPICALACZONE
1​
ACNE~TOPICALAMZEEQ
2​
ACNE~TOPICALEPIDUO FORTE
3​
ACNE~TOPICALEPIDUO FORTE
3​
ACNE~TOPICALONEXTON
4​
ACNE~TOPICALRETIN-A MICRO
5​
ACNE~TOPICALRETIN-A MICRO
5​
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
What is the desired format of your unique serial number?
Assuming if column A, B and D are duplicated then the serial number will also be duplicated?
 
Upvote 0
What is the desired format of your unique serial number?
Assuming if column A, B and D are duplicated then the serial number will also be duplicated?
Hi Candyman8019,

Column D is just a reference of what I should get with a formula and it is not part of the criteria. For example for the ACNE~ISOTRETINOIN therapeutic class, I will get only 1 as a serial number because that therapeutic class only has one drug and the same serial number will be applied to the drug's duplicate values.
The next therapeutic class ACNE - TOPICAL has five drugs so the serial number will start again with 1 for the first drug and its duplicates, then 2 for the second drug and its duplicates, then 3 for the third drug and its duplicates, and so on. in conclusion, a new therapeutic class will always start with number 1 for the first drug and its duplicates and then adding +1 to the additional drugs within that therapeutic class. Basically, I am counting all the drugs within a therapeutic class.

Thank you for your assistance.
 
Upvote 0
Give this a try:
book5.xlsm
ABC
1THERAPEUTIC_CLASSDRUG_NAMESequence
2ACNE~ISOTRETINOINABSORICA1
3ACNE~ISOTRETINOINABSORICA1
4ACNE~ISOTRETINOINABSORICA1
5ACNE~ISOTRETINOINABSORICA1
6ACNE~ISOTRETINOINABSORICA1
7ACNE~ISOTRETINOINABSORICA1
8ACNE~ISOTRETINOINABSORICA1
9ACNE~ISOTRETINOINABSORICA1
10ACNE~ISOTRETINOINABSORICA1
11ACNE~ISOTRETINOINABSORICA1
12ACNE~TOPICALACZONE1
13ACNE~TOPICALACZONE1
14ACNE~TOPICALAMZEEQ2
15ACNE~TOPICALEPIDUO FORTE3
16ACNE~TOPICALEPIDUO FORTE3
17ACNE~TOPICALONEXTON4
18ACNE~TOPICALRETIN-A MICRO5
19ACNE~TOPICALRETIN-A MICRO5
Sheet4
Cell Formulas
RangeFormula
C3:C19C3=+IF(A3=A2,IF(B3=B2,C2,IF(A3=A2,C2+1,1)),1)
 
Upvote 0
The above is assuming the list is sorted by column A, then Column B.
 
Upvote 0
Thank you very much Candyman8019! The formula worked perfectly for my 50K records! I really appreciate your assistance and expertise.
 
Upvote 0

Forum statistics

Threads
1,214,846
Messages
6,121,905
Members
449,054
Latest member
luca142

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top