本文介绍了Excel返回多个唯一值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个公式:

INDEX($A:$A;RANDBETWEEN(1;COUNTA($A:$A));1)

将值从列返回到单元格。它工作正常,但是我需要返回4个值,我需要所有的值都是唯一的。任何想法?

to return values from a column to a cell. It works fine, but I need to return 4 values total, and I need all of them to be unique. Any ideas?

推荐答案

使用如下公式:

=INDEX(A:A,AGGREGATE(15,6,ROW($A$1:$A$26)/(COUNTIF($C$1:C1,$A$1:$A$26)=0),RANDBETWEEN(1,ROWS(A1:A26)-ROW(1:1)+1)))

使用您的本地设置:

=INDEX(A:A;AGGREGATE(15;6;ROW($A$1:$A$26)/(COUNTIF($C$1:C1;$A$1:$A$26)=0);RANDBETWEEN(1;ROWS(A1:A26)-ROW(1:1)+1)))

由于这是指公式上面的单元格,它必须放在第二行或下一行, $ C $ 1:C1 必须直接指向公式第一个实例上方的单元格。

Since this does refer to the cells above the formula it must be placed in the second or lower row and the $C$1:C1 must refer to the cell directly above the first instance of the formula.

然后拖动它下降了4倍。

Then drag it down 4 times.

Aggregate是一个数组公式类型。引用应仅包括数据集的引用。应避免使用完整的列引用,因为它将强制总计进行比所需更多的计算,并在此特定情况下返回空格。

Aggregate is an array formula type. The references should only include those of the data set. Full column references should be avoided as it will force the Aggregate to do more calculations than needed, and will return blanks in this specific case.

仅自动包含数据集,根据列A中的数据增长或缩小,请使用以下命令:

To automatically include only the data set, grow or shrink depending on the data in column A, use this:

=INDEX(A:A;AGGREGATE(15;6;ROW($A$1:INDEX(A:A;MATCH("zzz";A:A)))/(COUNTIF($C$1:C1;$A$1:INDEX(A:A;MATCH("zzz";A:A)))=0),RANDBETWEEN(1;ROWS($A$1:INDEX(A:A;MATCH("zzz";A:A)))-ROW(1:1)+1)))






编辑#1


Edit #1

要拖动到右边使用这个:

To drag to the right use this:

=INDEX($A:$A;AGGREGATE(15;6;ROW($A$1:INDEX($A:$A;MATCH("zzz",$A:$A)))/(COUNTIF($B$2:B2;$A$1:INDEX($A:$A;MATCH("zzz";$A:$A)))=0);RANDBETWEEN(1;ROWS($A$1:INDEX($A:$A;MATCH("zzz";$A:$A)))-COLUMN(A:A)+1)))

并更改 $ B $ 2:B2 到第一个公式的第一个放置位置的单元格。

And change the $B$2:B2 to the cell directly left of the first placement of the formula.

这篇关于Excel返回多个唯一值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 10:01
查看更多