![]() |
Range objects in a collection
Hello,
I've been trying to store a number of ranges in a collection, but instead of storing the range it seems to store the cells value. The purpose here is to add to the collection as needed and at the end print out the contents with workbook, worksheet and cell reference for each item. Dim initRange as Range Set initRange = worksheets("sheet1").Range("$A$1") ' contents = 48 Dim myCollection as New Collection myCollection.Add(initRange) Dim tempRange as Range Set tempRange = myCollection.Item(1) 'fails with object required error Any suggestions, or am I stuck using an array of ranges? Thanks, Corey |
Range objects in a collection
On myCollection.Add(initRange), lose the ()'s. These are causing initRange
to be evaluated before the add. Or add Call, Call myCollection.Add(initRange), whch requires ()'s to enclose the argument. "Corey B" wrote in message om... Hello, I've been trying to store a number of ranges in a collection, but instead of storing the range it seems to store the cells value. The purpose here is to add to the collection as needed and at the end print out the contents with workbook, worksheet and cell reference for each item. Dim initRange as Range Set initRange = worksheets("sheet1").Range("$A$1") ' contents = 48 Dim myCollection as New Collection myCollection.Add(initRange) Dim tempRange as Range Set tempRange = myCollection.Item(1) 'fails with object required error Any suggestions, or am I stuck using an array of ranges? Thanks, Corey |
All times are GMT +1. The time now is 03:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com