ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   processing part of a collection (https://www.excelbanter.com/excel-programming/294380-processing-part-collection.html)

ksnapp[_46_]

processing part of a collection
 
hello,

This is the next step in the last code i posted. I looks at a rang
and makes the cell values items in a colection. THen thing i can'
seem to do now is process the items.

each item is test to see if it has a length less than four if it doe
than its supposed to add "0" to the front the item until it has
length of four.

the problem occurs when it get to a line that reads:

COL1.Item(I) = 0 & COL1.Item(I)

it gives me a runtime error highlighting that line and says objec
required.

I can't think of an object to put in there


here is the whole code:


Sub collection()

Dim COL1 As New collection
Dim REPL As Variant
Dim FRST As Variant
Dim SCND As Single

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

For I = 1 To 4
If Len(COL1.Item(I)) < 4 Then
Do Until Len(REPL) = 4
COL1.Item(I) = 0 & Item.COL1(I)
Loop

End If
Next

FRST = COL1(1) & COL1(2) & COL1(3) & COL1(4)
SCND = Len(FRST)

MsgBox (SCND)
MsgBox (FRST)

End Sub


can you process items in a collection idividuall

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



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

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