Ok, but can I ask why? To a lot of people, the word "Error" carries connotations of bad or a mistake. The computer makes no such distinction. Error is just a condition as is No Error.
Just for the sake of an example, lets assume each grain of sand on the beach is etched with a unique ID. You need to find (if it exists) and pick up the grain with the ID "1234"
There is the loop, which works but could take a tremendously long time:
For Each oGrain In Beach.Grains
If oGrain.ID = "1234" Then
'Whatever"
Exit For
End If
Next
Or the explicit Set method using an Error handler. Always fast.
On Error Resume Next
Set oGrain = Beach.Grains("1234")
On Error GoTo 0
If Not oGrain is Nothing Then
'Whatever
End If
|