When dealing with Excel spreadsheets, there arise numerous instances where you need to extract a random number or character from a specific range. You might have heard about the RAND() function, but do you know its syntax and how to employ it? This article will outline the syntax and usage of the RAND() function. Stay tuned!

Description
The RAND() function yields a random real number, greater than or equal to 0 and less than or equal to 1.
Syntax
= RAND()
The function takes no parameters.
Additionally, the RAND() function can assist you in obtaining a random number within any two specified values.
To obtain a random number greater than or equal to 0 and less than n, use the following syntax.
=RAND() * n
If you want to extract a random number greater than or equal to m and less than n, apply the following syntax.
=RAND() * (n - m) + m
Note
The RAND() function is a volatile function, meaning its result changes when you update or reopen the spreadsheet.
If you want a constant result, follow these steps: after entering the RAND() function, press the F9 key, and then press Enter. This way, it will generate a random number at the time of entering the function and consistently use that number.
Example
Example 1: Utilize the RAND() function to retrieve a random number.

Example 2: Retrieve a random positive integer with x digits.
You can use the formula to obtain a random number within a range:
=RAND() * (n - m) + m
To obtain a random number with a fixed number of digits, set n=10^x and m=10^(x-1) where x is the desired number of digits.
Then, use the INT() function to get the positive integer of the RAND() function.
=INT(RAND() * (n - m) + m)
For example, retrieve a random positive integer with 5 digits.

Example 3: Retrieve a random character.
In addition to generating a random number, the RAND() function can also produce a random character.
For instance, obtain a random character from the English alphabet.
The English alphabet consists of 26 letters, so first, generate a random integer between 1 and 26.
=INT(RAND() * 26 + 1)
According to the ANSI character set, uppercase letters (A to Z) range from ANSI code 65 to ANSI code 90. Next, use the CHAR() function to return the result as a character.
=CHAR(INT(RAND() * 26 + 1) + 64)

Similarly, random lowercase letters (a to z) are in the range of ANSI code 97 to ANSI code 122. Use the CHAR() function to obtain the result as a character.
=CHAR(INT(RAND() * 26 + 1) + 96)

Thus, the article has provided you with detailed guidance on the RAND() function and how to use it through specific examples. Hopefully, after reading this article, all of you will be able to utilize the RAND() function when needed. Wishing you all success!