ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with collections (https://www.excelbanter.com/excel-programming/294369-help-collections.html)

ksnapp[_45_]

Help with collections
 
Im trying to learn how to use collections

for this example i've but 4 digit numbers in the cells C2:F2.
at this point i just want to get the data into a collection and the
look at the items individually in a msg box

here is my code thus far.


Sub collection()

Dim COL1 As New collection
Dim FRST
Dim SCND
Dim THRD
Dim FRTH

Range("c2:F2").Select
For Each cell In Selection
COL1.Add (cell.Value)
Next cell

FRST = COL1.Item(1).Value

MsgBox (FRST)

End Sub

help i just don't get i

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Help with collections
 
Try changing

FRST = COL1.Item(1).Value

to

FRST = COL1.Item(1)

or

FRST = COL1(1)


probably not a good idea to vcall the sub collection


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ksnapp " wrote in message
...
Im trying to learn how to use collections

for this example i've but 4 digit numbers in the cells C2:F2.
at this point i just want to get the data into a collection and then
look at the items individually in a msg box

here is my code thus far.


Sub collection()

Dim COL1 As New collection
Dim FRST
Dim SCND
Dim THRD
Dim FRTH

Range("c2:F2").Select
For Each cell In Selection
COL1.Add (cell.Value)
Next cell

FRST = COL1.Item(1).Value

MsgBox (FRST)

End Sub

help i just don't get it


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 06:35 PM.

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