通过使用公式生成不重复的随机数 [英] Generate random numbers which do not repeat by using formulas

查看:151
本文介绍了通过使用公式生成不重复的随机数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想生成4个0到20之间的随机数,它们之间不会重复.即,对于每个后续生成的随机数,它必须排除任何先前生成的随机数的值.

I want to generate 4 random numbers between 0 and 20 which do not repeat among themselves. i.e. For each subsequent generated random number, it must exclude the value of any previously generated random numbers.

例如

第二个生成的随机数必须不等于第一个,第三个必须不等于第一和第二个,最后第四个必须不等于第一,第二和第三.

The 2nd generated random number must not be equal to the 1st one, the 3rd one must not be equal to the 1st and 2nd ones, and finally the 4th one must not be equal to the 1st, 2nd, and 3rd ones.

如何使用Excel公式实现这一目标?

How to achieve that using Excel formulas?

推荐答案

将此内容放入A2:

=AGGREGATE(15,6,(ROW($1:$21)-1)/(COUNTIF($A$1:A1,(ROW($1:$21)-1))=0),RANDBETWEEN(1,22-ROW(1:1)))

并复制四个单元格.

这篇关于通过使用公式生成不重复的随机数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆