With Collection / Dictionary...Delete Rows with a specific text in one cell and the Row above it. Example if F5 contains the word Duplicate, then delete Rows 5 & 4.
Below is the code I've been using. It may need rewritten to accomplish the multiple row deletions.
Dim colDupes As New Collection
Dim lEntry As Long, LstRow As Long, lrow As Long, LstCol As Long
Dim rng As Range
For lrow = 1 To LstRow
On Error Resume Next
strKey = Cells(lrow, "F")
With dicDupes
.Add strKey, strKey
If Err.Number <> 0 Then
colDupes.Add strKey, strKey
End If
End With
On Error GoTo 0
Next
With rng
If colDupes.Item(lEntry) = "Redundant" Then
'This is where it breaks down
.Offset(-1, 0).EntireRow.Delete
End With
Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>
Our community of experts have been thoroughly vetted for their expertise and industry experience.