Try shortening it
shown = rng.SpecialCells(xlCellTypeVisible).Count
"whitehurst" wrote:
Can somebody please explain where my misunderstanding of
SpecialCells(xlCellTypeVisible) is?
Example, a completely new workbook:
1. Name range "A1:E10" as "test".
2. Insert the following macros:
Public Function total(rng As Range)
total = rng.Cells.Count
End Function
Public Function shown(rng As Range)
shown = rng.SpecialCells(xlCellTypeVisible).Cells.Count
End Function
3. Insert '=total(test)' and '=shown(test)' into 2 cells not in the
range.
4. Both should say 50. Now, start hiding rows/columns intersecting the
'test' range. Even when using Ctrl-Alt-F9, the shown count always
equals 50 - why?! Hide all the cells in the range - still 50?! Why?
Does SpecialCells(xlCellTypeVisible) not do what I think it should?
Thanks!
--
whitehurst
------------------------------------------------------------------------
whitehurst's Profile: http://www.excelforum.com/member.php...o&userid=34544
View this thread: http://www.excelforum.com/showthread...hreadid=550123