View Single Post
 
Old 05-29-2018, 06:56 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote