View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Removing a collection item via key name check

There can't be duplicate keys, so just add the new item and do
On Error Resume Next. If the key was there already the item won't be added.

RBS

wrote in message
ups.com...
I have a collection of range objects, called collXcells, and each has a
key cooresponding to the range's R1C1 position (each range is only 1
Excel cell). I.e. if there is a range object that is the A3 cell, its
key for collXcells is "R3C1".

Is there any easy way to check if a key in the collection exists? and
if so remove the item associated with that key? (a way easier--and
preferably more efficient-- than looping through all the collection
objects keys, that is).

Thanks,

-Abe