I need to create a unique ID for tracking stuff and I've used the following to do it for now, but it's not ideal as I need to scale this ability to others as well.
Current solution:
1) Open spreadsheet, insert a new column and find First Name(E2) and Last Name(D2) fields and adjust the following formula to match:
2) I then copy the column, insert a new column at A and then Paste/Special/Values so that the Rand doesn't change
3) Delete the original new column and I have static unique id's.
I've been trying to automate this with a macro, but I'm failing miserably as this is as far as I've gotten and I've probably lost 10 - 15 hours of my life, so any help would be appreciated.
Current solution:
1) Open spreadsheet, insert a new column and find First Name(E2) and Last Name(D2) fields and adjust the following formula to match:
Excel Formula:
=YEAR(NOW())&"-"&(LEFT(E2,1)&(LEFT(D2,1)&(RANDBETWEEN(10000,10000000000)&"-"&TODAY()-DATE(YEAR(NOW()),1,1)+1)))
3) Delete the original new column and I have static unique id's.
I've been trying to automate this with a macro, but I'm failing miserably as this is as far as I've gotten and I've probably lost 10 - 15 hours of my life, so any help would be appreciated.
VBA Code:
Sub Method2()
Sheets.Select
Dim LastName As Range
Dim FirstName As Range
Dim FName As String
Dim FColumn As Long
Dim LName As String
Dim LColumn As Long
FName = "First Name"
LName = "Last Name"
Set FirstName = Range("A:Z").Find(FName, , xlValues, xlWhole, xlByColumns)
FColumn = ActiveCell.Column
Cells(1, 1) = FColumn
Set LastName = Range("A:Z").Find(LName, , xlValues, xlWhole, xlByColumns)
LColumn = ActiveCell.Column
Cells(2, 1) = LColumn
Last edited by a moderator: