View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
stevec stevec is offline
external usenet poster
 
Posts: 177
Default Delete Rows in Worksheet2 that Match Criteria in Worksheet1!A1:A20

I have a macro put together by Ron de Bruin a fewmonths ago... wondering how
I can modify it so that it will delete rows in worksheet2 if ColB in
Worksheet2 contain values referenced in Worksheet1!A1:A200.

In otherwords, how can I modify the line DeleteValue = "*Total*" to
make this work?

thanks very much!



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

DeleteValue = "*Total*"
With ActiveSheet
.Range("A1:A1000").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.EntireRow.Delete

End With
.AutoFilterMode = False
End With
End Sub