Why would the white block of 0449 above the purple block of 0449 not be deleted if:
Then identify all other rows of data that have the same obligation number and delete them.
The following hides the rows for now, until we are sure it is right.
Sub ASDelete()
Dim rngCell As Range
Dim rngCell2 As Range
Dim rngObligor As Range
Dim rngAccID As Range
Dim rngNumber As Range
Dim calcState As Long
Set rngObligor = Sheets("Sheet1").Range("A2", Range("A2").End(xlDown))
Set rngAccID = Sheets("Sheet1").Range("H2", Range("H2").End(xlDown))
calcState = Application.Calculation
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
For Each rngCell In rngAccID
If rngCell.Value = "COF01" Then
Set rngNumber = rngCell.Offset(0, -7)
For Each rngCell2 In rngObligor
If rngCell2 = rngNumber Then
rngCell2.EntireRow.Hidden = True
End If
Next
End If
Next
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = calcState
End With
End Sub
Bookmarks