ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add Unique item to Collection (https://www.excelbanter.com/excel-programming/288661-add-unique-item-collection.html)

Dick Kusleika[_3_]

Add Unique item to Collection
 
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.



Jim Cone

Add Unique item to Collection
 
Dick
It works for me in XL2002 without an error.
Regards,]
Jim Cone
San Francisco, CA

"Dick Kusleika" wrote in message
...
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.




Bob Phillips[_6_]

Add Unique item to Collection
 
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)

"Dick Kusleika" wrote in message
...
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.





Dick Kusleika[_3_]

Add Unique item to Collection
 
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" wrote in message
...
Dick
It works for me in XL2002 without an error.
Regards,]
Jim Cone
San Francisco, CA

"Dick Kusleika" wrote in message
...
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.






Ron de Bruin

Add Unique item to Collection
 
Hi dick

No error for me in XL 2000,WinXP

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Dick Kusleika" wrote in message ...
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.





Dick Kusleika[_3_]

Add Unique item to Collection
 
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

"Ron de Bruin" wrote in message
...
Hi dick

No error for me in XL 2000,WinXP

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Dick Kusleika" wrote in message

...
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.







Ron de Bruin

Add Unique item to Collection
 
Send me your test workbook if you want Dick.
I can test it again for you

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Dick Kusleika" wrote in message ...
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

"Ron de Bruin" wrote in message
...
Hi dick

No error for me in XL 2000,WinXP

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Dick Kusleika" wrote in message

...
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.









Andy Pope

Add Unique item to Collection
 
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 Kusleika wrote:

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


Dick Kusleika[_3_]

Add Unique item to Collection
 
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

"Andy Pope" wrote in message
...
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 Kusleika wrote:

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





All times are GMT +1. The time now is 04:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com