简体   繁体   English

从 Excel 中的列范围动态提取唯一值列表?

[英]Dynamically extract a list of unique values from a column range in Excel?

I found this example in an excel tutorial我在excel教程中找到了这个例子

The following image is my desired result.下图是我想要的结果。 and the following formula is supposed to be able to extract the unique records dynamically.并且下面的公式应该能够动态提取唯一记录。 I know how to do this with VBA but i really want to make this a formula without using a macro.我知道如何用 VBA 做到这一点,但我真的想把它变成一个不使用宏的公式。

=IFERROR(INDEX($B$2:$B$9, MATCH(0,COUNTIF($D$1:D1, $B$2:$B$9), 0)),"")

I have tried the above formula as given in the example link above but it returns with error.我已经尝试了上面示例链接中给出的上述公式,但它返回错误。 I am assuming that this worked at some point in excel however it no longer works with Excel 2016. Can someone clarify why this formula no longer works?我假设这在 excel 中的某个时候有效,但它不再适用于 Excel 2016。有人可以澄清为什么这个公式不再有效吗? Thank you.谢谢你。 在此处输入图片说明

Answering my own question about 5 minutes later, so i read the patch nodes on the how match changed from excel 2008 to 2016. You need to use the index rather than the count.大约 5 分钟后回答我自己的问题,所以我阅读了关于匹配如何从 excel 2008 更改为 2016 的补丁节点。您需要使用索引而不是计数。

=IFERROR(INDEX($B$2:$B$9, MATCH(0,INDEX(COUNTIF($D$1:D1,$B$2:$B$9),0,0),0)),"0)),"")")

Recommended edit to the formula to change the value returned on error to a blank: =IFERROR(INDEX($B$2:$B$9, MATCH(0,INDEX(COUNTIF($D$1:D1,$B$2:$B$9),0,0),0)),"")建议编辑公式以将错误返回的值更改为空白: =IFERROR(INDEX($B$2:$B$9, MATCH(0,INDEX(COUNTIF($D$1:D1,$B$2:$B$9),0,0),0)),"")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM