+ Reply to Thread
Results 1 to 6 of 6

Generating of unique random set length numerical codes

  1. #1
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Generating of unique random set length numerical codes

    I am after a way to have a cell highlighted to input the code length, between 4 - 7 digits say cell A1
    Each code can only use a numerical value between 0 - 9, and not use the same digit more than once.
    Eg. 6 digit code could be 371409, but could not be something like 374380, as 3 is used twice.

    I would like a random list generated down column A from A2:A1000.

    How would this be accomplished?

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Generating of unique random set length numerical codes

    I know that there is probably an array formula to do this.

    But my prefferred route would be a custom Macro.

    It will take ten minutes to write. BRB


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mehmetcik; 10-02-2014 at 06:47 AM.

  3. #3
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Generating of unique random set length numerical codes

    vba macro
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Generating of unique random set length numerical codes

    If the cells are formatted as text then line 200 can be modified to:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: Generating of unique random set length numerical codes

    Quote Originally Posted by mehmetcik View Post
    I know that there is probably an array formula to do this.

    But my prefferred route would be a custom Macro.

    It will take ten minutes to write. BRB


    Please Login or Register  to view this content.
    Thank you very much for the reply, and workbook.
    Seems to be te trick.
    Modified to the below to suit a set code length:
    Please Login or Register  to view this content.
    ONLY issue i am having, is that any changes to other cells in the sheet, changes the codes each time.
    Last edited by coreytroy; 10-03-2014 at 04:20 AM.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Generating of unique random set length numerical codes

    Try this version.

    Two Changes
    1. it stops the UDF working if B2 is changed to 0
    2. it stops picking numbers if it has the number of digits specified by B2
    [ Similar to your modification, but why pick 5 digits if you are going to ditch them?]

    Please Login or Register  to view this content.

+ 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. How to generate unique random alphanumeric 32 character codes?
    By JussiR in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-21-2014, 06:30 AM
  2. Generating a list of Random numbers of random length...
    By Growl in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-19-2013, 12:10 PM
  3. Replies: 1
    Last Post: 01-22-2013, 03:45 PM
  4. [SOLVED] Generating unique random number
    By Fuhgawz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-09-2012, 05:26 PM
  5. Generate unique random alphabets for 35 characters in length
    By promo786 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-13-2011, 11:10 PM

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