Run Time Error 91 on Cell.Find

KnoxBear832

New Member
Joined
Aug 25, 2014
Messages
4
Using FIND in my code and getting a run-time error even with a ON ERROR GOTO line preceding the FIND line.

I'm trying to increase the row height of the cell that contains a particular text value. The sheet may or may not have that text and it's not always in the same cell, so I thought the ON ERROR / FIND combination would be best. I am using it multiple times in the macro and it seems to be working find, except for this last instance. What am I doing wrong??
Here is the code:

Code:
On Error GoTo Laststep    Cells.Find(What:="Sample Text", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
    ActiveCell.RowHeight = 12.75
Laststep:
    Range("A2").Select
       
End Sub


I just tried this bit by itself and it seems to work fine. There must be something before this that interferes. Any ideas on what I may need to clear?
 
Last edited:

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,246
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Here's another way that doesn't require error handling.

Code:
Dim R As Range

Set R = Cells.Find(What:="Sample Text", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)
If Not R Is Nothing Then R.RowHeight = 12.75
 

Watch MrExcel Video

Forum statistics

Threads
1,109,549
Messages
5,529,466
Members
409,883
Latest member
asharris90
Top