I want to create a random string with random length from the alphabet in Excel. For example, "jlskdjf", "kjlk", "kljsodif", etc. How can I do that?
BasicAssume you want to generate a random length (1-8 characters) string from lower case alphabets (a-z).
Each To use upper case alphabets (A-Z) instead of lower case, you can replace To simply the formula, you can use AdvancedAssume you want to generate a random length (1-8 characters) string from specific characters. You can input the desired characters in cell A1, for example:
Then,
Each |
|||
|
|
|
Hmm. It would be pretty easy with VBA to make a function to do it. With formulae it's a little more involved.
There might be an easier way, with array formulae or something. |
|||
|
|
As a formula for a single character you could use this
Just look in any ACSII-Table to select your desired rand range. But the random length is tricky, not because of the random length, but because of the random characters you want to put together. Otherwise, you could just the REPT function joined with RAND function and the formula above. But to fit your described result, I would use this code:
If there is a solution to do this code with formulas, hence without VBA, I would very much like to know about it :) |
|||
|
|
|
|
|||
|
|
