Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Collection won't store string
- Sub TestCollection()
- Dim i As Single, col As New Collection
- Dim vArr(1 To 3) As String
- 'For i = LBound(vArr) To UBound(vArr)
- ' vArr(i) = Sheets("Sheet2").Cells(1, i)
- 'Next i
- vArr(1) = "String 1"
- vArr(2) = "String 2"
- vArr(3) = "String 3"
- For i = LBound(vArr) To UBound(vArr)
- Debug.Print vArr(i)
- col.Add i, vArr(i)
- Debug.Print col(i)
- Next i
- End Sub
- Item 1 -> "String 1"
- Item 2 -> "String 2"
- Item 3 -> "String 3"
- Item 1 -> 1
- Item 2 -> 2
- Item 3 -> 3
- vArr(1) = "String 1"
- vArr(2) = "String 2"
- vArr(3) = "String 3"
- For i = LBound(vArr) To UBound(vArr)
- col.Add vArr(i), CStr(i)
- Sheet1.Cells(1, i) = col.Item(i)
- Next i
- vArr(1) = "String 1"
- vArr(2) = "String 2"
- vArr(3) = "String 3"
- For i = LBound(vArr) To UBound(vArr)
- col.Add vArr(i)
- Sheet1.Cells(1, i) = col.Item(i)
- Next i
- Dim i As Single, col As New Collection
- Dim vArr(1 To 3) As String
- vArr(1) = "Column 1"
- vArr(2) = "Column 2"
- vArr(3) = "Column 3"
- For i = LBound(vArr) To UBound(vArr)
- col.Add i, vArr(i)
- Next i
- For i = LBound(vArr) To UBound(vArr)
- Dim columnNumber As Integer
- columnNumber = col("Column 2")
- Sheet1.Cells(1, columnNumber).Value = "Found it"
- Next i
- col.Add vArr(i), CStr(vArr(i))
- col.Add vArr(i), CStr(i)
Add Comment
Please, Sign In to add comment