The RAND function returns a random real number, greater than or equal to 0 and less than and equal to 1
In the process of working with Excel spreadsheets, there will be many cases where you need to get a random number, a character in a certain range. You may have heard of the RAND () function, but you do not know the syntax and how to use the function. The following article will describe the syntax and usage of the RAND () function, please follow along!
Description
The RAND () function returns a random real number, greater than or equal to 0 and less than and equal to 1.
Syntax
= RAND ()
Function without parameters.
The RAND () function can also help you get a random number between any two values.
- To get a random number greater than or equal to 0 and less than n, you use the syntax.
= RAND () * n
- To get a random number greater than or equal to m and less than n, you use the syntax.
= RAND () * (n - m) + m
Note
- The RAND () function is a modified function, so the results of the RAND () function will change when you update or reopen the spreadsheet.
- If you want the results to not change, you do the following: when you have finished entering the RAND () function, press F9 and then press Enter. This will take a random number at the time of entering the function and then always use that number.
For example
Example 1: Use the RAND () function to get a random number.
Example 2: Take a positive integer random number, including x digits.
You use the formula to get random numbers in the range:
= RAND () * (n - m) + m
To get random numbers that fix the number of digits, you would set n = 10 ^ x and m = 10 ^ (x-1) where x is the number of digits you want.
Then you use the INT () function to get positive integers of the RAND () function.
= INT (RAND () * (n - m) + m)
For example, take a random positive integer, consisting of 5 digits
Example 3: Get a random character.
The RAND () function, in addition to giving a random number, may also return a random character.
For example take a random character in the English alphabet.
The English alphabet has 26 letters so first you need to get a random integer between 1 and 26.
= INT (RAND () * 26 + 1)
According to ANSI encoding, uppercase characters (A to Z) range from ANSI 65 code to ANSI 90 code. Next use the CHAR () function to return the result as characters.
= CHAR (INT (RAND () * 26 + 1) + 64)
Similar to the random lowercase characters (a to z) from ANSI 97 to ANSI 122, use the CHAR () function to return the result as a character.
= CHAR (INT (RAND () * 26 + 1) + 96)
Thus, the article has guided you very detailed about the RAND () function and how to use the RAND () function through specific examples. Hopefully after this article, all of you can use the RAND () function as needed. Good luck!
You should read it
- BINOM.INV function - The function returns the smallest value with cumulative binomial distribution greater or equal to the standard value in Excel
- The function rand () in C
- Random function in Excel (RAND function), how to use the Random function and examples
- CEILING function in SQL Server
- How to generate random numbers in Google Sheets
- 1KB equals how many MB, GB, bytes, bits?
- FLOOR function in SQL Server
- 1 ton is equal to how many weights, oats and kgs
- The function srand () in C
- How to fix IRQL NOT LESS OR EQUAL errors on Windows
- How to split the desktop work on your computer into 2 equal areas
- How to Type Less than or Equal to