Generate ID for cells containing same values
Closed
cris01
-
Apr 21, 2015 at 06:34 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Contributor Last seen December 27, 2022 - Apr 21, 2015 at 11:08 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Contributor Last seen December 27, 2022 - Apr 21, 2015 at 11:08 AM
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 September 12, 2010
Status
Contributor
Last seen
December 27, 2022
555
Apr 21, 2015 at 11:08 AM
Apr 21, 2015 at 11:08 AM
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