简体   繁体   中英

Ignore blank cells in my Excel INDEX formula

I have the following table on Excel from A2-A10

YEAR
1999
1997

1999
1998
1998

1996
1999

=INDEX(SORT(UNIQUE($A$2:$A$10)),COLUMN((A1))) >>> (drag formula horizontally)

This is my output:

1996  1997 1998 1999 0     

The problem is that it keeps returning 0 because my range contains some blank cells. How can I ignore blanks using this formula?

three possibilities:

=INDEX(SORT(UNIQUE(IF($A$2:$A$10<>"",$A$2:$A$10,LARGE($A$2:$A$10;1)))),COLUMN((A1)))
=INDEX(SORT(UNIQUE(FILTER($A$2:$A$10,$A$2:$A$10<>""))),COLUMN((A1)))
=IFERROR(1/(1/INDEX(SORT(UNIQUE($A$2:$A$10)),COLUMN((A1)))),"")

Or skipping INDEX so you don't need to drag your formula to the right: =TRANSPOSE(SORT(UNIQUE(FILTER($A$2:$A$10,$A$2:$A$10<>""))))

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