Error 91

sweeneytime

Board Regular
Joined
Aug 23, 2010
Messages
183
Hi guys,

I am getting an "error 91 object variable not set". I have tried a few things and google but no joy. I just want the operation to finish so I can start another one. ps The symbol I'm searching for doesn't paste into here, box with a question mark in it.

Anybody got some idea's??

Thanks,
Alan

HTML:
Sub FindEnd()

    Dim Last As Long
    Last = Range("A" & Rows.Count).End(xlUp).Row
    
    
    For Each cell In Range("A1:A" & Last).Cells

        If Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
        xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate Then
        
            ActiveCell.Rows("1:19").EntireRow.Select
            Selection.Delete Shift:=xlUp
        Else
        End If
    Next cell
    
End Sub
When the error strikes it highlights
HTML:
If Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
        xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate Then
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Not sure about what's causing the error, but I tried to interpret your code (and I may be wrong). I'm wondering if this could be of use?

Code:
Sub sweeneytime()

    Dim Last As Long
    Dim rcell As Range
    
    
    Last = Range("A" & Rows.Count).End(xlUp).Row
    
      
    For Each rcell In Range("A1:A" & Last)
    
        If rcell.Text = "000" Then

            rcell.Resize(19).EntireRow.Delete Shift:=xlUp

        End If
    
    Next rcell
    
End Sub
 
Upvote 0
Hi John,

You are correct! Works perfectly. A nice shorter piece of code too that I will use again and again.

Cheers,
Alan
 
Upvote 0

Forum statistics

Threads
1,215,309
Messages
6,124,180
Members
449,146
Latest member
el_gazar

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