View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Macro to delete rows with different data

Try this for A3:A?

Change/add the names in the array
Array("jelle", "ron", "dave")

Sub Example3()
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
Dim StartRow As Long
Dim EndRow As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 3
EndRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For Lrow = EndRow To StartRow Step -1

If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf Not IsError(Application.Match(.Cells(Lrow, "A").Value, _
Array("jelle", "ron", "dave"), 0)) Then .Rows(Lrow).Delete

End If
Next
End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Tasha" wrote in message ...
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!!!