Find that doesn't Find

Norton5150

New Member
Joined
Jul 11, 2003
Messages
22
I have this statement in the middle of a For Next loop

TB_Val = Range("F" & R.Find(What:=TB_Lookup).Row).Value

Trouble is when I try to Find a value that doesn't exist, I get a run-time error '91', object variable or with block variable not set

I've tried handling this with error handling and also with turning off alerts, but neither one helped me.

My Error handling I tried, On Error Resume Next, which ironically seemed to work 1 time through the loop then ignored that.

Thoughts? Thanks
 

Some videos you may like

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
You probably just need to clear the error:

Code:
On Error Resume Next
TB_Val = Range("F" & R.Find(What:=TB_Lookup).Row).Value
If Err <> 0 Then
   Err.Clear
Else
' Code if no error
End If
On Error GoTo 0
 

Watch MrExcel Video

Forum statistics

Threads
1,118,820
Messages
5,574,509
Members
412,599
Latest member
Schu94
Top