Forum Discussion

Pete_Atkinson's avatar
Pete_Atkinson
Copper Contributor
Jan 10, 2022
Solved

Creating a Random Code Generator

Hi, I hope someone can help me with this.   I want to create random codes using certain letters i.e. no vowels and numbers.   I would also like to create random codes of varying lengths, sometim...
  • mtarler's avatar
    mtarler
    Jan 11, 2022

    Pete_Atkinson so that can't be the 'whole' formula you posted as it isn't even valid.  There is probably additional lines you just don't see.  Regardless, here is a formula to use:

    =CONCAT(MID($B$2,RANDARRAY($B$3,1,1,LEN($B$2),TRUE),1))

     B2 has the list of valid characters and B3 is how long you want the code to be.

    See the attached sheet.

    since you specifically asked to know how it works:

    the RANDARRAY creates an array of B3 number of values between 1 and the total length of the list of valid characters (B2).

    the MID() looks at the list of valid characters (B2) and pulls out the character located according to the RANDARRAY

    and finally CONCAT puts it all together

Resources