+ Reply to Thread
Results 1 to 4 of 4

Generate GUID, Find Duplicates, Replace, Rescan

  1. #1
    Registered User
    Join Date
    05-31-2010
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    15

    Generate GUID, Find Duplicates, Replace, Rescan

    I needed a way to generate GUIDs, which I've found, but I need to ensure they are truly unique. Here is the script that generates the GUIDs

    Please Login or Register  to view this content.
    Here is the script that scans for duplicates. I need a couple changes, but I don't know how to do them. First, I need it generate the GUIDs with the above script. I'm guessing that can be a separate process. Second, I need it to scan the list it just made, If it finds a duplicate, I need it to replace the entry with another GUID, not delete it. Once it regenerates, I need it to rescan the list from the beginning, finishing out with truly, verified, unique IDs.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Generate GUID, Find Duplicates, Replace, Rescan

    Try with this code:
    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Generate GUID, Find Duplicates, Replace, Rescan

    Hello talkinggoat,

    Here is the correct method of generating GUIDs. This uses a system API call devloped by Microsoft to aid software developers.
    Please Login or Register  to view this content.


    Example of Using the GUID Function Call
    Please Login or Register  to view this content.


    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Press the keys ALT+F11 to open the Visual Basic Editor
    4. Press the keys ALT+I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL+V
    7. Make any custom changes to the macro if needed at this time.
    8. Save the Macro by pressing the keys CTRL+S
    9. Press the keys ALT+Q to exit the Editor, and return to Excel.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Generate GUID, Find Duplicates, Replace, Rescan

    Just for fun here is a formula to generate a PseudoGUID, it would be extremely unlikely to generate a duplicate, definately not on the same machine!

    I used a similar technique to generate unique order numbers as we had people on different sites needing to create unique order numbers, each order number had Time and Date encoded along with other information so we could verify a real order number!

    ="{"&RIGHT("00000000"&CHAR(RANDBETWEEN(48,57))&DEC2HEX(LEFT((CHAR(RANDBETWEEN(48,57))&RIGHT("000000"&TODAY(),6)&CHAR(RANDBETWEEN(48,57))&RIGHT(REPT("0",15)&(MOD(NOW(),1)*10^15),15)&CHAR(RANDBETWEEN(48,57))),9)),8)&"-"&RIGHT("0000"&CHAR(RANDBETWEEN(48,57))&DEC2HEX(MID((CHAR(RANDBETWEEN(48,57))&RIGHT("000000"&TODAY(),6)&CHAR(RANDBETWEEN(48,57))&RIGHT(REPT("0",15)&(MOD(NOW(),1)*10^15),15)&CHAR(RANDBETWEEN(48,57))),10,5)),4)&"-"&DEC2HEX(RANDBETWEEN(0,65535),4)&"-"&DEC2HEX(CHAR(RANDBETWEEN(48,57))&RIGHT((CHAR(RANDBETWEEN(48,57))&RIGHT("000000"&TODAY(),6)&CHAR(RANDBETWEEN(48,57))&RIGHT(REPT("0",15)&(MOD(NOW(),1)*10^15),15)&CHAR(RANDBETWEEN(48,57))),10),10)&DEC2HEX(RANDBETWEEN(0,256^3),6)&"}"
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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