AUTOFILTER

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I have an Excel worksheet and I am trying to find a way to delete
selected lines via VB, can any one help me please. Thanks
 
there is another solution by David Hawley

Sub DeleteRowsBasedOnCriteria()
'Assumes the list has a heading.

With ActiveSheet
'If filters are not visible then turn them on
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
'Set the filters in A1 to show only rows to delete
.AutoFilter Field:=1, Criteria1:="Delete"
'Delete all visible cells under the heading.
.Cells(1, 1).CurrentRegion.Offset(1, 0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
'Remove filters
.AutoFilterMode = False
End With
End Sub
==================
 

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

Back
Top