Trying to assertain why this macro will not work.
If Not IsError(.Value) works fine with one item
but If Not IsError(Application.Match(.Value, _ - will not delete the row items from the list in col A
What am I missing - End If is active with If Not IsError(.Value) but compile error end if w/o block if
Sub Delete_Row_IfCellContainsCertainText()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
.DisplayPageBreaks = False
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
For Lrow = Lastrow To Firstrow Step -1
With .Cells(Lrow, "A")
' If Not IsError(.Value) Then
' If .Value Like "*CSB*" Then .EntireRow.Delete
If Not IsError(Application.Match(.Value, _
Array("*CSB *", "*Hanover County Community Svcs Board", "*Valley Community Service Board", "*District Three Transportation", "*MEOC *", "*Appalachian Agency For Senior Citizens, Inc.", "*Behavioral Health Associates", "*Franklin Co. Dept. of Aging", "*New River Valley Senior Services", "*Piedmont Senior Resources *", "*Lake Country AAA Inc.", "*Bay Aging - Bay Transit", "*Senior Services of Southeastern VA", "GAS*", "GR *", "VD *", "* PT *"), 0)) Then .EntireRow.Delete
' End If
End With
Next Lrow
End With
ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
Bookmarks