Error 424 Object not found

silentwolf

Well-known Member
Joined
May 14, 2008
Messages
1,216
Office Version
  1. 2016
Hi got following code to delet entire row if an word is chosen in an input box.

Code:
Sub a()
Dim rngReporter As Range, strErsteAdresse As String, Suchbegriff

Suchbegriff = InputBox("Suche nach", Title:="Löschen")
If Len(Suchbegriff) > 0 Then
    With ActiveSheet.UsedRange
         Do
              Set rngReporter = .Find(Suchbegriff, lookat:=xlPart, LookIn:=xlValues, MatchCase:=False)
        If rngReporter Is Nothing Then Exit Do
              rngReporter.EntireRow.Delete
        Loop Until rngReporter.Address = strErsteAdresse
    End With
End If
However I do get an runtime error of 424 object not found in this line of code

Code:
        Loop Until rngReporter.Address = strErsteAdresse
does anyone know about this problem or knows how I could or need to change it so it works??
At the moment it findes me only one line and delete it :)

Thanks for any help!!
Albert
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi. You need to use a loop with FindNext. This is the example from the Help file:

Code:
With Worksheets(1).Range("a1:a500")
    Set c = .Find(2, LookIn:=xlValues)
    If Not c Is Nothing Then
        firstAddress = c.Address
        Do
            c.Interior.Pattern = xlPatternGray50
            Set c = .FindNext(c)
        Loop While Not c Is Nothing And c.Address <> firstAddress
    End If
End With
 
Upvote 0
Hi Vogt,
thanks for your reply! But as I am not that fit in VBA could you be so kind to let me know how my code would need to be changed??
I am sorry but just not sure.
Thanks

Albert
 
Upvote 0
Try

Code:
Sub a()
Dim rngReporter As Range, strErsteAdresse As String, Suchbegriff
On Error Resume Next
Suchbegriff = InputBox("Suche nach", Title:="Löschen")
If Len(Suchbegriff) > 0 Then
    With ActiveSheet.UsedRange
        Set rngReporter = .Find(Suchbegriff, lookat:=xlPart, LookIn:=xlValues, MatchCase:=False)
        If Not rngReporter Is Nothing Then
                strErsteAdresse = rngReporter.Address
            Do
                rngReporter.EntireRow.Delete
                Set rngReporter = .FindNext
            Loop While Not rngReporter Is Nothing And rngReporter.Address <> strErsteAdresse
        End If
    End With
End If
End Sub
 
Upvote 0
Hi VoG,
sorry I miss spelled your name first!!
It worked fantastic!!
Really appreciate your help alot!

Cheers
Albert
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,799
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top