Simply use the random number generater to generate a number between 26 and 97. This number cooresponds to the character (CHR()) of the letters a - z.
If you want to use other characters, here's a chart (use the decimal column).
Here's the function to generate a number between 2 numbers:
Function RandomNumber(LowNumber, HighNumber)Assign the function to a variable and pass in the LowNumber (26) and the HighNumber (97) and convert the value returned to the character it represents:
RANDOMIZE
RandomNumber = Round((HighNumber - LowNumber + 1) * Rnd + LowNumber)
End Function
RandomLetter = CHR(RandomNumber(97,122))That's it!
3 comments:
In the function. Do not use Round(...). Use Int(...) instead or you will find your characters returning 97-123 (adding the '{' character).
thank you, it helps me
Your function returns not only letters: numbers from 91 to 96 are special characters....
Post a Comment