Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You might consider using a Dictionary object rather than a
Collection object. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Chip. I hadn't run into dictionaries before, but I looked into
it and its definitely what I am looking for. -Abe Chip Pearson wrote: You might consider using a Dictionary object rather than a Collection object. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pivot Item: removing non-existant item from the drop down | Excel Programming | |||
Cannot remove item from collection | Excel Programming | |||
Check for an item in a collection (without looping) | Excel Programming | |||
Retrieving a Collection Item | Excel Programming | |||
Removing an Item From a Collection | Excel Programming |