Check if filtered cells contain data to delete

L

Les Stout

Hi all, I need a bit of help with code for the following. I am filtering
a column for certain criteria and i need to check if the other cells in
the filtered visual cells contain data, if no data continue with code
else delete rows visable only.

Selection.AutoFilter Field:=9, Criteria1:="=*za-t-m-**", Operator:=xlAnd


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
 
D

Dave Peterson

With Worksheets("sheet1")
If .AutoFilter.Range.Columns(1).Cells.SpecialCells(xlCellTypeVisible) _
.Count = 1 Then
'Only headers
MsgBox "nothing to delete"
Else
With .AutoFilter.Range
.Resize(.Rows.Count - 1).Offset(1, 0).EntireRow.Delete
End With
End If
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top