Re: count rows when worksheet is filtered
Quote from acw
Hi
That is right. SUMPRODUCT is one of those functions that won't work on an entire row or column selection. you could use A1:A65536 instead of A:A, but that is an overkill and slows processing.
Tony
Display More
Combat this by Defining the following names ...
BigStr
Refers to: =REPT("z",255)
Imp
Refers to: =Bau!$F$2:INDEX(Bau!$F:$F,MATCH(BigStr,Bau!$F:$F))
Stat
Refers to: =Bau!$G$2:INDEX(Bau!$G:$G,MATCH(BigStr,Bau!$G:$G))
That makes the range dynamic and keeps any subsequent function running fairly optimally, only checking the range being used. Caveat? You can't put any other data below, not being used, in those columns. And you can't use numbers, at least not as the bottom-most row, as it won't pick those up.
Also, the ShowAllData method will fail out if all of your filtered data already is at the All setting. You can bypass that by using an On Error Resume Next statement to test for this condition..
Sub ViewAll()
On Error Resume Next
Sheets("Bau").ShowAllData
End Sub
The only other thing the error could be is that there is no "Bau" sheets. While we know this is not the case, it is possible.
If you wanted to - although I don't know why - you could manually step through each field and reset it's filter ..
Sub ViewAll_Ver2()
Dim i%
For i = 1 To Sheets("Bau").AutoFilter.Range.Columns.Count
Sheets("Bau").AutoFilter.Range.AutoFilter field:=i
Next i
End Sub
HTH