本文共 2446 字,大约阅读时间需要 8 分钟。
表格范围内产生随机数
Google Sheets provides a simple function to generate random numbers inside your spreadsheet without having to leave the document or install an . The function returns a random integer between two values. Here’s how to use it.
Google表格提供了一种简单的功能,可以在电子表格内部生成随机数,而无需离开文档或安装 。 该函数返回两个值之间的随机整数。 这是使用方法。
Fire up the and open either a new or existing spreadsheet. For this guide, we’ll use the function RANDBETWEEN
to produce a .
启动然后打开一个新的或现有的电子表格。 在本指南中,我们将使用函数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)
After you fill in the range, press the Enter key. The random number will populate the cell where you entered the formula.
填写范围后,按Enter键。 随机数将填充您输入公式的单元格。
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.
如果要使用电子表格中其他单元格中的数字,则只需输入单元格号,而不要输入低号或高号。
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.
您可以选择“更改时”(默认),“更改时和每分钟”或“更改时和每小时”。 单击“保存设置”以返回到电子表格。
翻译自:
表格范围内产生随机数
转载地址:http://lefwd.baihongyu.com/