Sub Main()
Dim c As Range, cc As Range, r As Range, f As Range, i As Integer
Set r = Range("A1:AP1")
For Each c In r
Set f = FoundRangesB(r, c.Value2, False)
If Not f Is Nothing Then
'Rename cells if needed
i = 1
For Each cc In f
If Not c.Address = cc.Address Then
cc.Value2 = cc.Value2 & i
i = i + 1
End If
Next cc
End If
Next c
End Sub
Function FoundRangesB(fRange As Range, fStr As String, Optional tfBlanks As Boolean = True) As Range
Dim objFind As Range
Dim rFound As Range, FirstAddress As String
If fStr = "" And tfBlanks = False Then
Set FoundRangesB = Nothing
Exit Function
End If
With fRange
Set objFind = .Find(What:=fStr, after:=fRange.Cells((fRange.Rows.Count), fRange.Columns.Count), _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=True)
If Not objFind Is Nothing Then
Set rFound = objFind
FirstAddress = objFind.Address
Do
Set objFind = .FindNext(objFind)
If Not objFind Is Nothing Then Set rFound = Union(objFind, rFound)
Loop While Not objFind Is Nothing And objFind.Address <> FirstAddress
End If
End With
Set FoundRangesB = rFound
End Function