在 Excel 中生成一个表格,其中某些输出出现 x 次

在 Excel 中生成一个表格,其中某些输出出现 x 次

我正在尝试在 Excel 中重新创建代号,而我缺少的最后一件事是创建名称的“地图”,它看起来像这样。

这

基本上,它是一张桌子,其中 9/8 个点是蓝色,8/9 个点是红色,一个是黑色,其余是白色。

答案1

要使用公式执行此操作,它将采用 Office 365 订阅中提供的动态数组公式:

=CHOOSE(INDEX(UNIQUE(RANDARRAY(100000,,1,25,TRUE)),SEQUENCE(5,,0)*5+SEQUENCE(1,5)),"B","B","B","B","B","B","B","B","R","R","R","R","R","R","R","R",CHOOSE(RANDBETWEEN(1,2),"B","R"),"Bl","W","W","W","W","W","W","W")

UNIQUE(RANDARRAY(100000,,1,25,TRUE))以随机模式构建 1 到 25 之间的数字数组。

INDEX(...,SEQUENCE(5,,0)*5+SEQUENCE(1,5))将它们构建成一个 5 x 5 的数组。

然后,CHOOSE 会将正确的颜色作为单词放置在正确的单元格中,并CHOOSE(RANDBETWEEN(1,2),"Blue","Red")随机选择“额外”是黑色还是红色。


要使用正常公式,需要一个辅助列

=AGGREGATE(14,7,ROW($1:$25)/(COUNTIFS($Z$1:Z1,ROW($1:$25))=0),RANDBETWEEN(1,25-COUNT($Z$1:Z1)))

并向下复制25行。

在此处输入图片描述

然后将其放入 A1 中并复制 5 和 5:

=CHOOSE(INDEX($Z$2:$Z$26,(ROW(A1)-1)*5+COLUMN(A1)),"B","B","B","B","B","B","B","B","R","R","R","R","R","R","R","R",CHOOSE(RANDBETWEEN(1,2),"B","R"),"Bl","W","W","W","W","W","W","W")

然后只需创建条件格式规则即可将单词转换为颜色。

然后按 F9 进行另一个随机设计,以创建 1 到 25 之间的随机数。在 Z1 中输入,Helper然后在 Z2 中输入:

在此处输入图片描述

相关内容