J
Jag Man
I would like to have a Collection of Objects persist between Excel sessions.
I have done this
with arrays of strings using the Names feature, e.g.:
ActiveWorkbook.Names.Add Name:="testArray", RefersTo:=anArray
However, if I try to do it with a Collection, as shown below, I get a 1004
error.
What am I missing?
TIA
Ed
' testing use of Collection of objects as Names
Public Sub test5()
Dim i As Variant
Dim aCollection As Collection
Set aCollection = New Collection
For i = 0 To 5
aCollection.Add i, "i" & CStr(i)
Next i
Debug.Print aCollection("i2")
' doesn't work
'ActiveWorkbook.Names.Add Name:="testColl", RefersTo:=aCollection
End Sub
I have done this
with arrays of strings using the Names feature, e.g.:
ActiveWorkbook.Names.Add Name:="testArray", RefersTo:=anArray
However, if I try to do it with a Collection, as shown below, I get a 1004
error.
What am I missing?
TIA
Ed
' testing use of Collection of objects as Names
Public Sub test5()
Dim i As Variant
Dim aCollection As Collection
Set aCollection = New Collection
For i = 0 To 5
aCollection.Add i, "i" & CStr(i)
Next i
Debug.Print aCollection("i2")
' doesn't work
'ActiveWorkbook.Names.Add Name:="testColl", RefersTo:=aCollection
End Sub