ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   delete element is collection (https://www.excelbanter.com/excel-programming/401105-delete-element-collection.html)

Gary Keramidas

delete element is collection
 
how would i remove all elements from a variable set as new collection?

erase expects an array.

--


Gary




Jim Thomlinson

delete element is collection
 
Set your collection to nothing and then re-create it...

Dim col As Collection

Set col = New Collection
col.Add Sheet1, Sheet1.Name
col.Add Sheet2, Sheet2.Name
col.Add Sheet3, Sheet3.Name

MsgBox col.Item(Sheet2.Name).Name
Set col = Nothing
Set col = New Collection

--
HTH...

Jim Thomlinson


"Gary Keramidas" wrote:

how would i remove all elements from a variable set as new collection?

erase expects an array.

--


Gary





Gary Keramidas

delete element is collection
 

thanks jim, works for me.
--


Gary


"Jim Thomlinson" wrote in message
...
Set your collection to nothing and then re-create it...

Dim col As Collection

Set col = New Collection
col.Add Sheet1, Sheet1.Name
col.Add Sheet2, Sheet2.Name
col.Add Sheet3, Sheet3.Name

MsgBox col.Item(Sheet2.Name).Name
Set col = Nothing
Set col = New Collection

--
HTH...

Jim Thomlinson


"Gary Keramidas" wrote:

how would i remove all elements from a variable set as new collection?

erase expects an array.

--


Gary







Chip Pearson

delete element is collection
 
Set the collection variable to Nothing. E.g.,

Set MyCollection = Nothing


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
how would i remove all elements from a variable set as new collection?

erase expects an array.

--


Gary






All times are GMT +1. The time now is 07:16 AM.

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