Generate ID for cells containing same values
Closed
cris01
-
21 Apr 2015 à 06:34
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 21 Apr 2015 à 11:08
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 21 Apr 2015 à 11:08
Related:
- Based on the values in cells b77
- Name Values - Excel Forum
- Code to move rows into another sheet based on certain values ✓ - Excel Forum
- Based on the values in cells b77 b81 c77 - Excel Forum
- How do I get a value in a cell based on another cell - Excel Forum
- Looking For a Value in a Cell - Excel Forum
1 response
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
21 Apr 2015 à 11:08
21 Apr 2015 à 11:08
Hi Cristina,
The code below will do as requested.
The names are assumed to be in column A.
The ID's are assumed to be in column B.
Here is the code:
Best regards,
Trowa
The code below will do as requested.
The names are assumed to be in column A.
The ID's are assumed to be in column B.
Here is the code:
Sub RunMe()
Dim lRow, x As Integer
lRow = Range("A" & Rows.Count).End(xlUp).Row
x = 1
For Each cell In Range("A2:A" & lRow)
If cell.Offset(0, 1) = vbNullString Then
With Range("A2:A" & lRow)
Set c = .Find(cell.Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Offset(0, 1).Value = x
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
x = x + 1
End If
Next cell
End Sub
Best regards,
Trowa