View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rich Rich is offline
external usenet poster
 
Posts: 298
Default vba collection object in Excel

I haven't worked with vba collection objects for a while and have sort of
forgotten some of the properties. Here is a code sample using a collection
object and the error I am getting when I try to perform a particular
operation: I am basically assigning values to the given Integer vars below
and then storing these vars (or their values) in the collection object col.
Then I want to change the value of one of the collection items but I get an
error -- as depicted beolw. Is there a way to get around this? Or should I
create class objects with properties instead and create my own collection
class?

Dim col As New Collection
Dim i1 As Integer, i2 As Integer, i3 As Integer, i4 As Integer
i1 = 10
i2 = 20
i3 = 30
i4 = 40

col.Add i1, "1"
col.Add i2, "2"
col.Add i3, "3"
col.Add i4, "4"

col("1") = 15 <--try to change value of this col itme - error here "object
required"