I know I am late for the party but this may help any future visitor so I will go ahead and post a solution.
The .Find is happening on wsWFD.Columns("E") so .FindNext should happen on that range.
BTW, deleting in a loop can be extremely slow. You may want to identify the rows that you want to delete and store them using UNION. Finally at the end of the code delete it all together.Code:Set rngfound = wsWFD.Columns("E").FindNext(rngfound)
Something like this (UNTESTED)
PS: Long time! How have you been?Code:Dim DelRange As Range Dim rng As Range Dim bCell As Range Set rng = wsWFD.Columns("E") With Sheet1 For lngRow = 2 To lngLastRowT Set rngfound = rng.Find(.Cells(lngRow, "E"), LookIn:=xlValues, LookAt:=xlWhole) If Not rngfound Is Nothing Then Set bCell = rngfound Set DelRange = wsWFD.Rows(rngfound.Row) Do Set rngfound = rng.FindNext(rngfound) If Not rngfound Is Nothing Then If rngfound.Address = bCell.Address Then Exit Do If DelRange Is Nothing Then Set DelRange = wsWFD.Rows(rngfound.Row) Else Set DelRange = Union(DelRange, wsWFD.Rows(rngfound.Row)) End If Else Exit Do End If Loop End If If Not DelRange Is Nothing Then DelRange.Delete '~~> Set the range to nothing after deleting Set DelRange = Nothing End If '~~> This is important to avoid false positives Set rngfound = Nothing Next End With




Reply With Quote