G
Greg Maxey
I have some code that loads each building block from each template (in the
template collection) into a 2 dimensional array and then puts those items
into a UserForm combobox.
How can I sort this array so that the items listed in the combobox are
listed alphabetically? Thanks
Sub BuildList
Dim lngCount As Long
Dim i As Long
Dim j As Long
pStr = ""
lngCount = 0
For Each oTmp In Templates
For i = 1 To oTmp.BuildingBlockEntries.Count
If Left(oTmp.BuildingBlockEntries(i).Name, Len(pStr)) = pStr Then
lngCount = lngCount + 1
End If
Next
Next
If lngCount > 0 Then
ReDim bbArray(0 To lngCount - 1, 1 To 4)
Else
ReDim bbArray(0)
bbArray(0) = "No matching building block entries"
Exit Sub
End If
j = 0
'Load those building blocks into an array
For Each oTmp In Templates
For i = 1 To oTmp.BuildingBlockEntries.Count
If Left(oTmp.BuildingBlockEntries(i).Name, Len(pStr)) = pStr Then
bbArray(j, 1) = oTmp.BuildingBlockEntries(i).Name
bbArray(j, 2) = oTmp.FullName
bbArray(j, 3) = oTmp.BuildingBlockEntries(i).Value
bbArray(j, 4) = oTmp.BuildingBlockEntries(i).Index
j = j + 1
End If
Next
Next
Me.cbBuildingBlocks.List = bbArray()
End Sub
template collection) into a 2 dimensional array and then puts those items
into a UserForm combobox.
How can I sort this array so that the items listed in the combobox are
listed alphabetically? Thanks
Sub BuildList
Dim lngCount As Long
Dim i As Long
Dim j As Long
pStr = ""
lngCount = 0
For Each oTmp In Templates
For i = 1 To oTmp.BuildingBlockEntries.Count
If Left(oTmp.BuildingBlockEntries(i).Name, Len(pStr)) = pStr Then
lngCount = lngCount + 1
End If
Next
Next
If lngCount > 0 Then
ReDim bbArray(0 To lngCount - 1, 1 To 4)
Else
ReDim bbArray(0)
bbArray(0) = "No matching building block entries"
Exit Sub
End If
j = 0
'Load those building blocks into an array
For Each oTmp In Templates
For i = 1 To oTmp.BuildingBlockEntries.Count
If Left(oTmp.BuildingBlockEntries(i).Name, Len(pStr)) = pStr Then
bbArray(j, 1) = oTmp.BuildingBlockEntries(i).Name
bbArray(j, 2) = oTmp.FullName
bbArray(j, 3) = oTmp.BuildingBlockEntries(i).Value
bbArray(j, 4) = oTmp.BuildingBlockEntries(i).Index
j = j + 1
End If
Next
Next
Me.cbBuildingBlocks.List = bbArray()
End Sub