+ Reply to Thread
Results 1 to 9 of 9

Unique Identifier

Hybrid View

  1. #1
    Registered User
    Join Date
    07-15-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    19

    Unique Identifier

    I have 95 rows of data as follows:

    Mr/Ms., First Name, Middle Initial, Last name, Add1, Add2, City, State, Zip, Age. I would like to create a unique identifier ( 10 digit) for each that is not dependant on a any further calculation once established. If I choose to resort by last name, zip code, or city, the unique identifier MUST stay with the row assigned for confidential sales tracking purposes.

    Can this be done?

    Thank you in advance if it can.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,732

    Re: Unique Identifier

    Why a ten digit identifier if only 95 rows? Why not just number them 1-95? Simpler is often the answer.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    07-15-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    19

    Re: Unique Identifier

    Hello Alan, The marketing company between my data and the client wants a 10 digi number similar to a claim check # for anonymity. The more randomized the number, the better, in their way of thinking.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Unique Identifier

    Hi,

    It sounds like you will be creating a new 11th column for the unique ID. In which case as long as any sort includes all 11 columns then you will have no problems.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    07-15-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    19

    Re: Unique Identifier

    Hello Richard, I was thinking of doing a RANDBETWEEN but it recalculates on every sort.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Unique Identifier

    Quote Originally Posted by mussonip View Post
    Hello Richard, I was thinking of doing a RANDBETWEEN but it recalculates on every sort.
    ...Sorry, but what's the question?

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Unique Identifier

    One way:

    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    1
    Sal
    First
    MI
    Last
    Add1
    Add2
    Cit
    ST
    Zip
    Age
    CRC
    2
    Mr Bob A Smith 1234 Main St #201 Dallas TX
    75240
    22
    4,203,160,230
    K2: =GetCRC32(Cat(A2:J2, "|")) + 2^32
    3
    Mr Bob B Smith 1234 Main St #201 Dallas TX
    75240
    22
    2,231,331,328
    4
    Mr Bob B Smith 1234 Main St #201 Dallas TX
    75240
    23
    4,093,139,606


    Function Cat(vInp As Variant, _
                 Optional sSep As String = ",", _
                 Optional bCatEmpty As Boolean = False) As String
        ' Catenates the elements of vInp separated by sSep
        ' Empty values and null strings are ignored unless bCatEmpty is True
    
        Dim vItem       As Variant
        Dim sItem       As String
    
        If bCatEmpty Then
            For Each vItem In vInp
                Cat = Cat & CStr(vItem) & sSep
            Next vItem
    
        Else
            For Each vItem In vInp
                sItem = CStr(vItem)
                If Len(sItem) Then Cat = Cat & sItem & sSep
            Next vItem
        End If
    
        If Len(Cat) Then Cat = Left(Cat, Len(Cat) - Len(sSep))
    End Function
    
    Function GetCRC32(sInp As String)
        ' UDF wrapper for iCRC32
        GetCRC32 = iCRC32(StrConv(sInp, vbFromUnicode))
    End Function
    
    Function iCRC32(aiBuf() As Byte) As Long
        ' shg 2013
    
        Const iPoly     As Long = &HEDB88320
        Static aiCRC()  As Long
        Static bInit    As Boolean
    
        Dim iCRC        As Long
        Dim i           As Long
        Dim j           As Long
    
        If Not bInit Then
            ReDim aiCRC(0 To 255)
    
            For i = 0 To 255
                iCRC = i
    
                For j = 8 To 1 Step -1
                    If iCRC And 1 Then
                        iCRC = ((iCRC And &HFFFFFFFE) \ 2&) And &H7FFFFFFF
                        iCRC = iCRC Xor iPoly
                    Else
                        iCRC = ((iCRC And &HFFFFFFFE) \ 2&) And &H7FFFFFFF
                    End If
                Next j
    
                aiCRC(i) = iCRC
            Next i
            bInit = True
        End If
    
        Dim iLookup     As Integer
    
        iCRC32 = &HFFFFFFFF
    
        For i = LBound(aiBuf) To UBound(aiBuf)
            iLookup = (iCRC32 And &HFF) Xor aiBuf(i)
            ' shift right 8 bits:
            iCRC32 = ((iCRC32 And &HFFFFFF00) \ &H100) And &HFFFFFF
            iCRC32 = iCRC32 Xor aiCRC(iLookup)
        Next i
    
        iCRC32 = Not (iCRC32)
    End Function
    Last edited by shg; 10-07-2014 at 07:42 PM.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Unique Identifier

    Nice one SHG. I'll have to dissect it to see how it works.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Unique Identifier

    Thanks, CB.
    Last edited by shg; 10-07-2014 at 07:44 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Unique identifier for a row
    By drdavidge in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-12-2010, 11:52 PM
  2. [SOLVED] Need to automate unique identifier
    By MLK in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-22-2006, 04:25 PM
  3. [SOLVED] Unique identifier
    By Steve Barnett in forum Excel General
    Replies: 19
    Last Post: 01-06-2006, 07:30 AM
  4. Unique identifier
    By Steve Barnett in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 01-06-2006, 07:30 AM
  5. [SOLVED] Unique identifier
    By Steve Barnett in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 01-06-2006, 07:30 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1