Reputation: 1733
I have a Worksheet which contains:
WS1
ID
AlexandG
AlexandG
AlexandG
AlexandG
How do I go about having these cells auto-number to:
ID
AlexandG
AlexandG1
AlexandG2
AlexandG3
Any help is appreciated. Thanks.
Upvotes: 1
Views: 70
Reputation: 4566
Here is a quick script that I wrote. You can run this code in a module and it works relative to you selecting the first cell (AlexandG).
Sub ChangeNameModule()
Dim count As Integer ' to keep track of current number to be appended to cell's value
count = 0
Do While Not (ActiveCell.value = None) ' stop running when the cell is empty
If count = 0 Then
' do not add count to the cell
Else:
ActiveCell.value = "" & ActiveCell.value & count ' append count to the cell's value
End If
ActiveCell.Offset(1, 0).Range("A1").Select ' selects the cell below
count = count + 1
Loop
End Sub
Upvotes: 1