Prevent duplicates in creating client reference codes

brianfosterblack

Active Member
Joined
Nov 1, 2011
Messages
251
I need to create a client reference code for each of my clients using this formula
=IF(B3="","",UPPER("C"&LEFT(C3,3)&G3&"001"))
This is done in column A
However if the formula creates a duplicate reference code it needs to make the last number 002 or 003 or 004 until the result is unique
Is there a way to do this in a formula?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try

=IF(B3="","",UPPER("C"&LEFT(C3,3)&G3&"00"&COUNTIFS($B$3:B3,B3,$G$3:G3,G3,$C$3:C3,C3)))

the above counts if columns B,C and G are the same.
 
Upvote 0
Try

=IF(B3="","",UPPER("C"&LEFT(C3,3)&G3&"00"&COUNTIFS($B$3:B3,B3,$G$3:G3,G3,$C$3:C3,C3)))

the above counts if columns B,C and G are the same.
Thanks but this does not work. In my client list (column C) in rows 13 and 14 I have 2 clients
Creighton & Associates and
Creighton Gauteng
My clients list in column C only lists unique names but as you see if the first 3 letters are the same I am ending up with the same code
what I need is if I have a duplication of the first 3 letters in column C then the second one must be 002 the third 003 and so on. I do not think there will ever be more than 5 duplicates as my list is currently only coming up with 2 instances. Column B will never have duplicates and the duplicates in column G do not matter as these can have dozens of duplicates.

 
Upvote 0
How about
Excel Formula:
=IF(B3="","",UPPER("C"&LEFT(C3,3)&G3&TEXT(SUMPRODUCT((LEFT(B$3:B3,3)=LEFT(B3,3))*(G$3:G3=G3)),"000")))
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,656
Members
449,045
Latest member
Marcus05

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