Macro to delete rows with different data
Worked like a charm....thank you so much!!!!
"Dave Peterson" wrote:
One way:
Option Explicit
Sub testme02()
Dim myRng As Range
Dim FoundCell As Range
Dim wks As Worksheet
Dim myStrings As Variant
Dim iCtr As Long
myStrings = Array("D", "GL", "NO", "REPO", "RUN")
Set wks = ActiveSheet
With wks
Set myRng = .Range("a3:a" & .Rows.Count)
End With
For iCtr = LBound(myStrings) To UBound(myStrings)
Do
With myRng
Set FoundCell = .Cells.Find(what:=myStrings(iCtr), _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
lookat:=xlWhole, _
searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)
If FoundCell Is Nothing Then
Exit Do
Else
FoundCell.EntireRow.Delete
End If
End With
Loop
Next iCtr
End Sub
Tasha wrote:
I need a macro to find data in cell column 1, starting in cell A3 that
contains the data "D", "GL", "NO", "REPO" and "RUN". I need it to find these
cells, and if that cell contains any of the noted data above, to delete the
entire row. Can someone help me with this? I've tried using some of the
macros mentioned in this forum, but was only for one variable, and I wasn't
sure how to do it with multiple variables????
Any help appreciated!!!
--
Dave Peterson
|