'Press Alt + F11 to open the Visual Basic Editor (VBE)
'From the Menu, choose Insert-Module.
'Paste the code into the right-hand code window.
'Press Alt + F11 to close the VBE
'Go to Tools … Macro …. Macros and double-click DelRow_OnColumn
Sub DelRow_OnColumn()
Dim rng1 As Range, rng2 As Range, cel As Range
Dim FirstAddress As String
Dim AppCalc As Long
Dim MyArr
Dim varr
MyArr = Array("Widget1", "Product1")
Set rng1 = Intersect(ActiveSheet.UsedRange, Columns("A"))
If rng1 Is Nothing Then Exit Sub
With Application
AppCalc = .Calculation
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
For Each varr In MyArr
Set cel = rng1.Find(varr, , xlValues, xlPart, xlByRows)
If Not cel Is Nothing Then
FirstAddress = cel.Address
Do
Set cel = rng1.FindNext(cel)
'test to avoid ending up with mutliple selections in one row to delete
If cel.Address <> FirstAddress Then
If Not rng2 Is Nothing Then
Set rng2 = Union(rng2, cel)
Else
Set rng2 = cel
End If
End If
Loop While FirstAddress <> cel.Address
End If
Next varr
If Not rng2 Is Nothing Then rng2.Clear
With Application
.ScreenUpdating = True
.Calculation = AppCalc
End With
|