Hi Team,
I want to autofilter a data and before deleting data
I want to check whether there are any visible cells after autofilter and then delete data.
I know two methods to validate.
1) 'If .Columns(1).SpecialCells(12).Count > 1 Then 'Criteria to validate
2) If WorksheetFunction.Subtotal(3, .Columns(8)) > 1 Then
Are there any other method to check visible cells?.. plz share
--------------------Below is Sample Data----------
Thanks
mg
I want to autofilter a data and before deleting data
I want to check whether there are any visible cells after autofilter and then delete data.
I know two methods to validate.
1) 'If .Columns(1).SpecialCells(12).Count > 1 Then 'Criteria to validate
2) If WorksheetFunction.Subtotal(3, .Columns(8)) > 1 Then
Are there any other method to check visible cells?.. plz share
VBA Code:
Sub Autofilter_Testing()
Sub Check_Visible_Cells
Dim lastrow As Long
lastrow = Range("a" & Rows.Count).End(xlUp).Row
With Range("a1").CurrentRegion
.AutoFilter field:=8, Criteria1:="<5"
'-----Check Point 1 validate visible cells----------
'If .Columns(1).SpecialCells(12).Count > 1 Then 'Criteria to validate
'-----Check Point 2 validate visible cells -----
If WorksheetFunction.Subtotal(3, .Columns(8)) > 1 Then
.Offset(1).Resize(.Rows.Count - 1).EntireRow.Select
.Cells.AutoFilter
Else
.Cells.AutoFilter
End If
End With
End sub
--------------------Below is Sample Data----------
Thanks
mg