Hi!

I am trying to create a macro that checks all cells in range for a match, and if found will delete a part of the range.
Everything works fine until my code deletes the first cells of the range, then on the next loop, it crashes with runtime error 424 objecr required.

This has to have something to do with the original range changing right? Is there a way how to continue my loop?

Sub removeshitcodes()

Dim FoundOne As range, LookInR As range, lookforshitcode As range
lastrowshitcode = Worksheets("HelperSheet").Cells(Rows.Count, "D").End(xlUp).Row

Set LookInR = Worksheets("valve data").range("BL4:GA" & lastrow)
Set lookforshitcode = Worksheets("HelperSheet").range("D2:D" & lastrowshitcode)

For Each C In lookforshitcode
        With LookInR
            Set FoundOne = .Find(What:=C, LookAt:=xlPart)
             If Not FoundOne Is Nothing Then
             For Each Cell In LookInR
                If Cell.Value = FoundOne Then
                shitcodecount = shitcodecount + 1
                Set panelrange = range(Cell.Offset(0, -5), Cell)
                panelrange.Delete shift:=xlToLeft
                End If
             Next Cell
            End If
        End With
    Next C
    
    Set LookInR = Nothing: Set lookforshitcode = Nothing


End Sub