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
- 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
May be interested
- Summary of data functions in Excelthis article will summarize the functions and uses of each function in the data function group (database funtions) in excel.
- Create different Headers and Footers in one Word documentthe following article shows you how to create multiple headers and footers in the same word document using microsoft word 2007, 2010, 2013.
- Turn off turn on the character repeat function in Excelin excel, when you enter content into a cell and then you enter the content below that cell with the same characters as the first character of the cell content above. the contents of the upper cell will be suggested to display in the lower box.
- Instructions for creating a cover page in Wordwhen you edit documents or documents in microsoft word, creating a cover for your documents to attract readers is essential. the beautiful cover page and the content of the document will be more interesting for the reader.
- ABS function (absolute value calculation) in Excelwhen you need to calculate absolute values for numbers in excel spreadsheets, you can use the abs function to calculate. the abs function helps you calculate the absolute value of a number, an expression or reference containing a number.
- CONCATENATE function (string concatenation function) in Exceluse the concatenate function when you want to concatenate existing text strings into a single, complete text string. for the syntax and usage of the concatenate function, follow the article below.