![表格范围内产生随机数](https://i-blog.csdnimg.cn/blog_migrate/84bcd3fcd986e4382815d98fec731f3c.png)
表格范围内产生随机数
![Sheets Header](https://i-blog.csdnimg.cn/blog_migrate/746b3ae6eab330688a581c98ff081534.png)
Google Sheets provides a simple function to generate random numbers inside your spreadsheet without having to leave the document or install an add-on. The function returns a random integer between two values. Here’s how to use it.
Google表格提供了一种简单的功能,可以在电子表格内部生成随机数,而无需离开文档或安装插件 。 该函数返回两个值之间的随机整数。 这是使用方法。
Fire up the Google Sheets homepage and open either a new or existing spreadsheet. For this guide, we’ll use the function RANDBETWEEN
to produce a random number.
启动Google表格首页,然后打开一个新的或现有的电子表格。 在本指南中,我们将使用函数RANDBETWEEN
产生一个随机数 。
By default, the RAND
function only generates a number between 0 (inclusive) and 1 (exclusive), whereas RANDBETWEEN
lets you specify a range of numbers. While you could modify the function to generate other ranges, the RANDBETWEEN
function is a much simpler way to accomplish this.
默认情况下, RAND
函数仅生成介于0(含)和1(不含)之间的数字,而RANDBETWEEN
允许您指定数字范围。 尽管可以修改该函数以生成其他范围,但是RANDBETWEEN
函数是实现此目的的一种简单得多的方法。
Click on a cell where you want to insert a random number and type =RANDBETWEEN(<Low>, <High>)
but replace <Low>
and <High>
with the range in which you want the random number to fall.
单击要插入随机数的单元格,然后键入=RANDBETWEEN(<Low>, <High>)
但将<Low>
和<High>
替换为希望随机数落入的范围。
For example, if you want a random number between 1 and 10, it should look like this:
例如,如果您想要一个介于1到10之间的随机数,则它应如下所示:
=RANDBETWEEN(1,10)
![Type the function in to a cell, enter the low and high end of the random range, and then press the Enter key.](https://i-blog.csdnimg.cn/blog_migrate/d6c54f87c823f74e243a31b8b18045ea.png)
After you fill in the range, press the Enter key. The random number will populate the cell where you entered the formula.
填写范围后,按Enter键。 随机数将填充您输入公式的单元格。
![After you press Enter, the random number will appear in the cell.](https://i-blog.csdnimg.cn/blog_migrate/1076991d48b7898eeaddda2126fb8d64.png)
If you want to use a number from another cell in your spreadsheet, all you have to do is enter the cell number instead of a low or high number.
如果要使用电子表格中其他单元格中的数字,则只需输入单元格号,而不要输入低号或高号。
![Use data from other cells when you type in the cell number instead.](https://i-blog.csdnimg.cn/blog_migrate/c9f56883d04e7afb56fe579f1e54118c.png)
Note: Both RAND
and RANDBETWEEN
are considered volatile functions, meaning they don’t retain the data in the cell forever. So, when you’re using either of the functions, they recalculate a new number each time the sheet changes.
注意: RAND
和RANDBETWEEN
均被视为易失性函数,这意味着它们不会永远将数据保留在单元中。 因此,当您使用任何一个函数时,每次工作表更改时,它们都会重新计算一个新的数字。
If you want to change the interval in which your random number is recalculated, open up File > Spreadsheet Settings, click on the “Calculation” tab, and then choose how often you want the function to recalculate from the drop-down menu.
如果要更改重新计算随机数的间隔,请打开“文件”>“电子表格设置”,单击“计算”选项卡,然后从下拉菜单中选择希望函数重新计算的频率。
You can select “On Change” (default), “On Change and Every Minute,” or “On Change and Every Hour.” Click “Save Settings” to return to your spreadsheet.
您可以选择“更改时”(默认),“更改时和每分钟”或“更改时和每小时”。 单击“保存设置”以返回到电子表格。
![Change the recalculation interval from File > Spreadsheet settings, click on "Calculation," and then choose the interval from the dropdown menu under "Recalculate."](https://i-blog.csdnimg.cn/blog_migrate/00e3c4b3ab679482052065103dced316.png)
翻译自: https://www.howtogeek.com/445056/how-to-generate-random-numbers-in-google-sheets/
表格范围内产生随机数