View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
David McRitchie David McRitchie is offline
external usenet poster
 
Posts: 903
Default Can't trap error when checking for keys not in Collection

I presume you included on error resume goto
for your error handler.


msgbox err.code & " -- " & err.description

to identify the actual error, you can then code off of the err.code
to do what you want.
--
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"BW" wrote in message ...
Hello,

For some reason when i try to remove a key from a Collection where that key
hasn't been added yet, i cannot trap the error when it occurs within an error
handler. All i get is a error dialog box that pops up that says "Invalid
procedure call or argument"

the code snippet is as follows:

On Error GoTo ERR_HANDLER
myCollection.Remove ("key1")
.
.
.
ERR_HANDLER:
.code here does not get executed when "key1" does not exist in myCollection.

How i can trap this error and continue processing?