You, yourself, brings up a very interesting point in using a Collection in order to achieve something parallel as to what you are looking for. It is not the same as a Type...End Type Construct, but it is similar. In a Collection, individual Items can be Set/Retrieved by using its Key Argument, (String) as indicated below:
-
Dim col As New Collection
-
Dim varCol As Variant
-
Dim intCtr As Integer
-
Dim strItem As String
-
-
For intCtr = 1 To 100
-
col.Add Item:=intCtr ^ 2, Key:="Item#" & CStr(intCtr)
-
Next
-
-
strItem = "Item#" & CStr(75)
-
-
Debug.Print "The 75th Item in the col Collection is: [" & FormatNumber(col(strItem), 0) & "]"
-
-
'Clear the Collection
-
For intCtr = 1 To 100
-
col.Remove 1
-
Next
OUTPUT of Debug.Print
- The 75th Item in the col Collection is: [5,625]