J
johli
Hi
Have some problems here that I hope someone smarter than me can
solve...
I'm trying to find the number of cells in an autofilter range matching
a specific criteria but I can't even get a correct count of all visible
cells.
Have tried the following code:
Function CountRows()
Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range
CountRows = rng.Columns(1).SpecialCells(xlVisible).Count - 1
End Function
This will always return all cells not just the visible ones...
If I run a Sub as a macro like:
Sub CountRows()
Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range
msgbox rng.Columns(1).SpecialCells(xlVisible).Count - 1
End Sub
It will return the correct count...
WHY??? Why doesn´t the function do the same when used in the
worksheet??
/Regards Johan
Have some problems here that I hope someone smarter than me can
solve...
I'm trying to find the number of cells in an autofilter range matching
a specific criteria but I can't even get a correct count of all visible
cells.
Have tried the following code:
Function CountRows()
Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range
CountRows = rng.Columns(1).SpecialCells(xlVisible).Count - 1
End Function
This will always return all cells not just the visible ones...
If I run a Sub as a macro like:
Sub CountRows()
Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range
msgbox rng.Columns(1).SpecialCells(xlVisible).Count - 1
End Sub
It will return the correct count...
WHY??? Why doesn´t the function do the same when used in the
worksheet??
/Regards Johan