Results 1 to 5 of 5

Thread: Developing a unique ID for new records

  1. #1
    Seeker Graeme Smith's Avatar
    Join Date
    Jul 2013
    Location
    Canberra Australia
    Posts
    9
    Articles
    0

    Developing a unique ID for new records



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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

  2. #2
    Something like

    MyUniqueID = Application.Evaluate("=A2&B2&C2&D2&E2")

  3. #3
    Magician NoS's Avatar
    Join Date
    Jan 2013
    Location
    British Columbia
    Posts
    675
    Articles
    0
    Excel Version
    Excel 2010 64bit
    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

    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
    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.

  4. #4
    Seeker Graeme Smith's Avatar
    Join Date
    Jul 2013
    Location
    Canberra Australia
    Posts
    9
    Articles
    0
    Thanks Bob for your assistance, greatly appreciated.

  5. #5
    Seeker Graeme Smith's Avatar
    Join Date
    Jul 2013
    Location
    Canberra Australia
    Posts
    9
    Articles
    0
    Thanks NoS for your assistance, greatly appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •