Hi,
I have an excel spreadsheet with about 20 fields. 2 of them include first_name and surname and I want to create a unique ID for each separate entry, however I don't want the same names getting different unique ID's. Can anyone help please??
Hi,
I have an excel spreadsheet with about 20 fields. 2 of them include first_name and surname and I want to create a unique ID for each separate entry, however I don't want the same names getting different unique ID's. Can anyone help please??
First, sort the rows by the lastname, firstname columns. Then use VBA (macro) code to assign the ID value. Like:Code:Sub NewID() Dim strName As String Dim intID As Integer Dim i As Integer i = 1 intID = 1 With Worksheets("Sheet1") strName = .Cells(i, 2).Value & .Cells(i, 3).Value While .Cells(i, 2).Value & "" <> "" If strName <> .Cells(i, 2).Value & .Cells(i, 3).Value Then intID = intID + 1 strName = .Cells(i, 2).Value & .Cells(i, 3).Value End If .Cells(i, 1).Value = "A" & intID i = i + 1 Wend End With End Sub
Thanks you so much. You have saved me a lot of work![]()
If this solution is good for you then go ahead and use the Thread Tools and mark this thread as Solved.