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
- ZTEST function - Returns the probability value on one side of the z test in Excelztest function: the function returns the one-sided probability value of the z test. for the hypothetical population mean, the function returns the probability that the sample mean will be greater than the sample mean observed in the data set or array.
- COUPNUM function - The function returns the number of interest payments on a security in Excelin the process of investing in securities, paying special interest is very important. it helps you calculate and plan a reasonable calculation and investment. the following article details the coupnum function - the function returns the number of interest payments of securities in excel.
- How to create random text in Wordsometimes, you need a text prepared in a word document for the purpose of presenting or paging the page. read the following article to learn how to do it.
- ISODD function - The function returns True if the value is an odd number in Excelisodd function: the function returns true if the value is odd. application of functions to check odd and even numbers. syntax: isodd (number)
- RANK.EQ function - Function returns the rank of a number in a list of numbers, returns the highest rank when multiple values with the same rank in Excelrank.eq function: the function returns the rank of a number in a list of numbers whose size is in correlation with other values. if multiple values have the same rank -> the function returns the highest rank. support functions from execl 2010 version onwards.
- The DAYS function - The function returns the number of days between 2 dates in Exceldays function: the function returns the number of days between 2 dates, the support function from excel 2013 onwards. syntax: days (end_date, start_date)
- TTEST - Returns the probability associated with a Student's t-Test in Exceldescription: the function returns the one-sided probability value of the z test. for the hypothetical population mean, the function returns the probability that the sample mean will be greater than the sample mean observed in the data set or array.
- PERMUTATIONA function - The function returns the number of permutations (can be repeated) of a given object in Excelpermutationa function: the function returns the number of permutations (can be repeated) of a given object. support functions from excel 2013 onwards. syntax: permutationa (number, number_chosen)
- NETWORKDAYS function - The function returns the number of whole working days between 2 dates in Excelnetworkdays function: the function returns the number of intact working days calculated between two specific dates. working days do not include weekends and holidays specified. syntax: networkdays (start_date, end_date, [holidays])
- TIME function - Function returns decimal numbers for a specific time value in Exceltime function: the function returns the decimal number for a time value. the decimal number that the function returns is from 0 to 0.99988426, which corresponds to the time from 0:00:00 (12:00:00 am) to 23:59:59 (11:59:59 pm). syntax: time (hour, minute, second)