Object = Nothing

Todd Bardoni

Well-known Member
Joined
Aug 29, 2002
Messages
3,042
How do I trap or test for an error where the object equals nothing?

Code:
Set OrderDetail = .document.all.Item("link_to_j26_button")
x = OrderDetail.Click
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
How about...


Code:
Set OrderDetail = .document.all.Item("link_to_j26_button")
If OrderDetail Is Nothing Then
    'Continue here....
End If
x = OrderDetail.Click
 
Upvote 0
I did and it doesn't work. I get that error message that says something about not having the block end if/with. And when i hit help it says the error was generated by an object being nothing. Then it says to re set it. But I don't know what exactly that means. re-set it to what? I just want to test if the object exists but I'm having a hard time. i could use On Error Goto...but this is in a loop and when it comes back around it triggers the Debug dialog box. If I use on Error resume next, then I get some results that I do not want. So, it would seem my only alternative is to test for it but the If statement doesn't work...
 
Upvote 0
Ugh, never mind...

I had:-
If OrderDetail = Nothing then...


It should be as Jaafar points out, Is Nothing...

Ughhh....
 
Upvote 0

Forum statistics

Threads
1,214,383
Messages
6,119,196
Members
448,874
Latest member
Lancelots

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