The problem was non-contigent areas in the filter result.
Give this a try.
Private Sub CommandButton1_Click()
Dim Rng As Range
Dim are As Range
Dim lngCount As Long
With Worksheets("Sheet1").ListObjects("Table1")
With .Range
.AutoFilter
.AutoFilter 2, Sheet1.Range("F2")
End With
On Error Resume Next
Set Rng = .DataBodyRange.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not Rng Is Nothing Then
For Each are In Rng.Areas
lngCount = lngCount + are.Rows.Count
Next are
Sheet1.Range("H2") = lngCount
Sheet1.Range("H5") = Rng.Row
Else
Sheet1.Range("H2") = "none"
Sheet1.Range("H5") = "No Row"
End If
End With
End Sub
PS Don't add On Error Resume Next anywhere else, if you encounter any other errors/problems post back.
Bookmarks