简体   繁体   中英

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

I found this example in an excel tutorial

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.

=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? 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.

=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)),"")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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