+ Reply to Thread
Results 1 to 11 of 11

Generating Random String from Text in Cells

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    23

    Generating Random String from Text in Cells

    We receive a spreadsheet of at least 60 people on a daily basis that contains the first name and last name of a person, each in its own cell. We have to manually generate IDs for all of these people. The requirements for these IDs are:

    • Must be preceded with "g4a"
    • Must not be longer than 8 characters in total
    • Must be random characters from the first and last name.

    An example would be if the person's name is John Doe their ID could be g4aeodjo (or any random characters found in their first and last name).

    Is there formula that can just generate these random IDs with the above requirements?

    Thank you in advance!!

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Generating Random String from Text in Cells

    Hi,

    So there is no restriction on repetition of characters (not given in your requirements)? Cases where the password consists of "g4a" followed by five identical characters (from the relevant name) are perfectly acceptable?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Generating Random String from Text in Cells

    =LOWER("g4a"&MID(CONCATENATE(A1,B1),RANDBETWEEN(1,LEN(CONCATENATE(A1,B1))),1)&MID(CONCATENATE(A1,B1),RANDBETWEEN(1,LEN(CONCATENATE(A1,B1))),1)&MID(CONCATENATE(A1,B1),RANDBETWEEN(1,LEN(CONCATENATE(A1,B1))),1)&MID(CONCATENATE(A1,B1),RANDBETWEEN(1,LEN(CONCATENATE(A1,B1))),1)&MID(CONCATENATE(A1,B1),RANDBETWEEN(1,LEN(CONCATENATE(A1,B1))),1))

    Assuming the first name is in A1 and last name is in B1

  4. #4
    Registered User
    Join Date
    01-18-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Generating Random String from Text in Cells

    Quote Originally Posted by XOR LX View Post
    So there is no restriction on repetition of characters (not given in your requirements)? Cases where the password consists of "g4a" followed by five identical characters (from the relevant name) are perfectly acceptable?
    Well, there can be identical characters but only the amount that is contained in the combined first name and last name. So, in John Doe there are 2 O's, so O can be used once or two times, but not 3 since there are only 2 O's in both the first and last name. I hope that makes sense!

  5. #5
    Registered User
    Join Date
    01-18-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Generating Random String from Text in Cells

    Quote Originally Posted by yudlugar View Post
    =LOWER("g4a"&MID(CONCATENATE(A1,B1),RANDBETWEEN(1,LEN(CONCATENATE(A1,B1))),1)&MID(CONCATENATE(A1,B1),RANDBETWEEN(1,LEN(CONCATENATE(A1,B1))),1)&MID(CONCATENATE(A1,B1),RANDBETWEEN(1,LEN(CONCATENATE(A1,B1))),1)&MID(CONCATENATE(A1,B1),RANDBETWEEN(1,LEN(CONCATENATE(A1,B1))),1)&MID(CONCATENATE(A1,B1),RANDBETWEEN(1,LEN(CONCATENATE(A1,B1))),1))

    Assuming the first name is in A1 and last name is in B1
    Just tried this and it did the trick! Thank you!

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Generating Random String from Text in Cells

    It will allow you to use each character in the name more than once...

  7. #7
    Registered User
    Join Date
    01-18-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Generating Random String from Text in Cells

    yudlugar, can the formula you provided be refined any further? Is there a way to limit the amount of repetition of the letters? Sometimes I'm getting IDs that are the same letter nearly all the way to the end. As I've explained to XOR LX, the repetition is allowed but only in the same amount of times the letter appears in the combined first and last name of each person.

    Thank you.

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Generating Random String from Text in Cells

    To get use each character only once I can't get it in a single cell formula but I think this works:
    A1: first name
    B1: last name
    C1: =LOWER("g4a"&MID(CONCATENATE(A1,B1),RANK(D1,D1:Y1),1)&MID(CONCATENATE(A1,B1),RANK(E1,D1:Y1),1)&MID(CONCATENATE(A1,B1),RANK(F1,D1:Y1),1)&MID(CONCATENATE(A1,B1),RANK(G1,D1:Y1),1)&MID(CONCATENATE(A1,B1),RANK(H1,D1:Y1),1))
    D1: =IF(COLUMN(A1)<LEN(CONCATENATE($A1,$B1)),RAND(),"")
    Then copy D1 across the row to whatever is a sensible limit for maximum characters in a name (say to BA1...)

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Generating Random String from Text in Cells

    Please see attached file with created IDs
    Attached Files Attached Files
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  10. #10
    Registered User
    Join Date
    01-18-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Generating Random String from Text in Cells

    Thank you for the ID Generator spreadsheet! This will help a lot. Going to start using it today.

  11. #11
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Generating Random String from Text in Cells

    Thanks for the feedback!

+ 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. 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
  2. Generating a Random Number of Random Numbers
    By Garrus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2010, 09:39 AM
  3. Randomly placing 5 same alphabet in a range of 20 cells. (Random Generating)
    By Excript in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-12-2009, 09:52 PM
  4. Replies: 1
    Last Post: 10-30-2008, 07:40 PM
  5. remove random spaces in a text string
    By mariusescu in forum Excel General
    Replies: 2
    Last Post: 07-10-2008, 03:32 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