Add Unique item to Collection

D

Dick Kusleika

I was pretty sure I knew how collections worked, but why do I get a run time
error (457) with this macro? Doesn't the On Error Resume Next trap that
error? XL2000, Win98SE.

Sub test()

Dim theColl As New Collection

theColl.Add "me", "me"
On Error Resume Next
theColl.Add "me", "me"
On Error GoTo 0

End Sub

Thanks.
 
J

Jim Cone

Dick
It works for me in XL2002 without an error.
Regards,]
Jim Cone
San Francisco, CA
 
B

Bob Phillips

Dick,

I don't get that error, it steps through nicely. XL2000, XP.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
D

Dick Kusleika

Jim

Thanks for checking. I don't remember any problems with collection in 2000,
but maybe there is. BTW, I tested it in XL97 and had no problem.

Dick

Jim Cone said:
Dick
It works for me in XL2002 without an error.
Regards,]
Jim Cone
San Francisco, CA

Dick Kusleika said:
I was pretty sure I knew how collections worked, but why do I get a run time
error (457) with this macro? Doesn't the On Error Resume Next trap that
error? XL2000, Win98SE.
Sub test()
Dim theColl As New Collection
theColl.Add "me", "me"
On Error Resume Next
theColl.Add "me", "me"
On Error GoTo 0
End Sub
Thanks.
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.
 
D

Dick Kusleika

Thanks Bob and Ron.

I don't know what the heck's going on here. I regserver'ed, code cleaned
and rebooted all to no avail. That's the extent of my troubleshooting
skills, so I'll be using a workaround until I can start messing with it.

Dick
 
A

Andy Pope

Hi Dick,

Sounds like you have the 'Break on all Errors' option set.
Check your VBE options, Error trapping is on the General tab.

Try one of the other 2 options.

Dick said:
I was pretty sure I knew how collections worked, but why do I get a run time
error (457) with this macro? Doesn't the On Error Resume Next trap that
error? XL2000, Win98SE.

Sub test()

Dim theColl As New Collection

theColl.Add "me", "me"
On Error Resume Next
theColl.Add "me", "me"
On Error GoTo 0

End Sub

Thanks.

--

Cheers
Andy

http://www.andypope.info
 
D

Dick Kusleika

Andy

Yep, that was it. I wonder how that got changed? I choose to believe that
it was a malicious virus instead of my own carelessness. Thanks.

Dick
 
Top