Answers for "vba collection add"

VBA
0

vba collection add

Sub TestCollection()
    ' Creation
    Dim myCol As New Collection
    ' Add items
    With myCol
        .Add "Something"
        .Add "Smth before", , 1     ' at first position
        myCol.Add "Blue", "color"
        .Add Item:=Date, Key:="Now"
        Debug.Print myCol.Count     ' > 4
    ' Get items (you can loop through Items collection)
        Debug.Print myCol(1)        ' > Smth before
        Debug.Print myCol("color")  ' > Blue
        Debug.Print .Item("Now")    ' > 26/03/2021
    ' Delete items
        .Remove (1)
        .Remove ("color")
    ' Clear
        Set myCol = New Collection
    End With
End Sub
Posted by: Guest on March-26-2021

Code answers related to "VBA"

Browse Popular Code Answers by Language