Something like
MyUniqueID = Application.Evaluate("=A2&B2&C2&D2&E2")
Hi, I am wanting to develop a bit of code for a userform that creates a unique ID for each new record added to the associated spread sheet. The unique ID would be made up of the first two characters of four or five columns. I tried to do this in the spreadsheet by concatenating and copying the formula down the column, however when a new record was added it was illustrated below the last cell of the formula, therefore I realised that it needs to be done as part of the coding for the userform.
I would greatly appreciate someones assistance in providing an example bit of code that I can utilise in the userform.
regards
Graeme
Something like
MyUniqueID = Application.Evaluate("=A2&B2&C2&D2&E2")
If the row of the columns that will be used for the unique id are to be populated from the userform you can create the id from the userform entries and populate the ID cell at the same time with something like this
Don't know what kind of info you are using to get the UniqueID from but suspect you will need to verify that MyUniqueID actually is unique.Code:MyUniqueID = Left(Me.TextBox1.Value, 2) & Left(Me.TextBox2.Value, 2) & Left(Me.TextBox3.Value, 2) & Left(Me.TextBox4.Value, 2) Sheets("Sheet1").range("A12").value = MyUniqueID
Thanks Bob for your assistance, greatly appreciated.
Thanks NoS for your assistance, greatly appreciated.
Bookmarks