vba - ListObject.DataBodyRange.SpecialCells(xlCellTypeVisible).Rows.count returns wrong value -


i have filtered list object , need number of rows visible. use statement number of lines:

mysheet.listobjects("mylistobject").databodyrange.specialcells(xlcelltypevisible).rows.count 

most of time works. when table has 1 or 2 rows visible, always returns 1, though should return 2 when there 2 rows. known issue? if so, there workarounds?

i'd rather avoid doing manual loop through every row in table count, can large , excessively slow.

further info: list object has totals row enabled, , filtered following code:

'remove existing filter mysheet.listobjects("mylistobject").range.autofilter  'apply new filter mysheet.listobjects("mylistobject").range.autofilter field:=1, criteria1:=key 

where field 1 (non-unique) key, , key string retrieved elsewhere. can physically see there 2 visible rows in table (not including header or totals row), yet .rows.count consistently returns 1 when there 2 rows.

that code incorrect - return number of rows in first visible contiguous block of cells in filtered table. should count number of visible cells in 1 column only:

mysheet.listobjects("mylistobject").databodyrange.columns(1).specialcells(xlcelltypevisible).count 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -