Filtered Data

  • Thread starter Thread starter Betty Csehi
  • Start date Start date
B

Betty Csehi

I have a list of data in a column. I want to filter that list for all of
the "XXX". I then want to delete the XXX items. Can I do this with
filtered data??
 
Hi Betty
- select your sorce range
- goto 'Data - Filter - Autofilter'
- filter all 'XXX'
- delete all rows with 'XXX' (all filtered rows'
- remove the Autofilter
 
Try this


For Column A

Sub Delete_with_Autofilter()
Dim DeleteValue As String
Dim rng As Range

DeleteValue = "XXX"

With ActiveSheet
.Columns("A").AutoFilter Field:=1, Criteria1:=DeleteValue
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.Delete Shift:=xlUp
End With
.AutoFilterMode = False
End With
End Sub
 
Thanks! I didn't know it would be so simple. Thought I'd lose all the
in-between data, but it looks fine. Thanks, again!
 

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