Dynamic ranges again - once more, with text strings

回眸只為那壹抹淺笑 提交于 2019-12-11 01:04:27

问题


I have a series of data sets (later to be used for populating comboboxes), and I've tried setting up dynamic ranges to list only the cells with useful data. In total, there are 160 rows of data, but the number of rows that will be populated will vary wildly.

In case it has a bearing on it (if the dynamic ranges detect "" as not blank, for example), the formula used to populate the cells in the range is

{=IF(ROW()-ROW(StartPort_NoBlanks)+1>ROWS(StartPort_Blanks)-COUNTBLANK(StartPort_Blanks),"",INDIRECT(ADDRESS(SMALL((IF(StartPort_Blanks<>"",ROW(StartPort_Blanks),ROW()+ROWS(StartPort_Blanks))),ROW()-ROW(StartPort_NoBlanks)+1),COLUMN(StartPort_Blanks),4)))}

(Based on @DennisWilliamson's answer at https://superuser.com/questions/189737/dynamically-updating-list-of-unique-column-entries-in-excel )

So far, I've tried both

='Saves_FilterLookups'!$C$3:INDEX('Saves_FilterLookups'!$C$3:$C$162, COUNTA('Saves_FilterLookups'!$C$3:$C$162))

and

=OFFSET('Saves_FilterLookups'!$C$3,0,0,COUNTA('Saves_FilterLookups'!$C:$C),1)

...but both give me the whole list, including the "blank" cells.

Most of the ranges contain text strings; one of the other ranges contains dates.

What am I missing? How do I fix it?

EDIT: To give a bit of context, here's a bit of the list. The full list contains entries scattered along its length, duplicates are removed into the second column, and they're all consolidated into a single block in the third column. They're then populated into the combobox in the userform, but all the blanks are coming in too...


回答1:


Here is a potential solution for you...the caveat is the cell above the list needs to be blank

=IFERROR(INDEX($A$2:$A$13,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$13),0,0),0)),"")

That will generate the list all in one step sorted and blanks removed.

I believe your COUNTA is your culprit. COUNTA will count all cells with something in them...and unfortunately "" is something. So you will need to eliminate the count of "". so I added a -COUNTIF and assumed the same range your were counting before. The worksheet name is not required if it is all being done on the same worksheet.

=OFFSET('Saves_FilterLookups'!$C$3,0,0,COUNTA('Saves_FilterLookups'!$C$3:$C$162)-COUNTIF('Saves_FilterLookups'!$C$3:$C$162,""),1)


来源:https://stackoverflow.com/questions/37700691/dynamic-ranges-again-once-more-with-text-strings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!