Prevent duplicates in creating client reference codes

brianfosterblack

Board Regular
Joined
Nov 1, 2011
Messages
189
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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

hajiali

Active Member
Joined
Sep 8, 2018
Messages
392
Office Version
  1. 2016
Platform
  1. Windows
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.
 

brianfosterblack

Board Regular
Joined
Nov 1, 2011
Messages
189
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.

 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,510
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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")))
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,510
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,441
Messages
5,636,305
Members
416,912
Latest member
danluk12

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
Top