Generating a unique reference code for a document list using an excel macro

xsound

New Member
Joined
Apr 14, 2019
Messages
1
Hi
I am helping my local historical society in a voluntary capacity to get their website on line. It will contain a catalogue of 400-500 documents. I have a list of them which I can get into excel.
In excel they appear as: column 1, a code for where they are in the filing cabinets, eg FC029-1,In column 2 is the document title.
Some have been digitised and the url consists of the ref code and title, as several of the ref codes are the same.
I have been trying to come up with a macro to update the ref code to of each document to make it unique. Thereby using only the new ref code as the url
I lack the knowledge of VBA Syntax to achieve this, but my thoughts are of a 1 to last row loop containing another loop that adds a char to the cell and the updates the char to next add if the ref is the same, then goes back to the first loop till all ref codes are different

So, something like

For i = 1 to lastrow
Z=cell(i,1)
C=65
For j=i to lastrow
If Cell( j,1)=Z
Then
( Cell(j) = Z & Chr(C)
C=C+1 )
Next
Next

Any help with the practical and correct syntax of the above will be gratefully received. Any comments about the logic or lack of it also welcome
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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