Assigning Unique Number to Text Duplicates

cadians

New Member
Joined
Jul 12, 2012
Messages
1
Good morning everyone,

I am interning at a large utility company and currently working in their commercial and industrial customer master file. My summer long project is to cleanse and reformat a lot of the data that has been extracted from SAP and other sources. I feel that a lot of the work is out of my realm of knowledge (which isn't much), but I actually have been able to complete a lot of the project steps myself until now.

They have asked that I assign a 5-digit unique ID to any customer that has mulitple premise locations.

This means that under the name column, the company's name appears more than once.

Here is a simplified example of what I'm working with and the formula I've come up with so far:

This formula is entered into ColumnC

=IF(MAX(COUNTIF(A3:$A$27,A3:$A$27))>1, RANDBETWEEN(9999,100000), IF(MAX(COUNTIF($B3:$B27,$B3:$B27))>1,RANDBETWEEN(9999,100000),""))


ColumnA ..... ColumnB ............. ColumnC
(Name) ... (Mailing Address) .... (Unique ID)

AAA ............. 111 .................. 49323
AAA ............. 111 .................. 49323
AAA ............. 111 .................. 49323
AAA ............. 111 .................. 49323
AAA ............. 111 .................. 49323
BBB ............. 222 ................... 98753
BBB ............. 222 ................... 98753
BB ............... 222 ................... 98753
BBB ............. 222 ................... 98753
BBB ............. 222 ................... 98753
CCC ............ 333 ................... 11365
CC .............. 333 ................... 11365
CCC ............ 333 ................... 11365
CCC ............ 333 ................... 11365
CCC ............ 333 ....................11365

As you can see, the names aren't always the same but the mailing address usually is (but not always, so I have to check them both). I have the formula check both column A and B. If a dup isn't found in Collumn A, then the formula checks Column B and generates a 5-digit random number if a dup is found.

Here is my issue:

The formula I'm using is just generating a random number for every row, and then also leaving some rows entirely blank.

If anyone could come up with a macro script in VBA to do this, that would be awesome.

Thank you in advance for your help.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,214,927
Messages
6,122,311
Members
449,080
Latest member
jmsotelo

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