Bom exemplo Mauro. Parabéns!
Mas então, tentei implementar no Collection e não consegui, neste teu exemplo ele repete os nomes e estou precisando usar sem repetições e de forma organizada.
Veja os dois sendo chamados no
Private Sub UserForm_Initialize()
Código: Selecionar todos
Private Sub Collection_ComboBox1()
Dim ULTLINHA, K As Long
Dim OCOLLECTION As New Collection
Dim VARVALUE As Variant
ULTLINHA = Worksheets("Plan1").Range("A65536").End(xlUp).Row
On Error Resume Next
For Each VARVALUE In Worksheets("Plan1").Range("A2:A" & ULTLINHA)
OCOLLECTION.Add VARVALUE, VARVALUE
Next
For K = 1 To OCOLLECTION.Count
ComboBox1.AddItem OCOLLECTION.Item(K)
Next K
End Sub
Código: Selecionar todos
Private Sub Ordenar_ComboBox1()
Dim iForsta, iSista As Integer
Dim i, j As Integer
Dim sTemp As String
Dim sCol As Integer
Dim ULTLINHA As Long
ULTLINHA = Worksheets("Plan1").Range("A65536").End(xlUp).Row
Set lastRow = Worksheets("Plan1").Range("A2:A" & ULTLINHA)
'adiciona dados
With ComboBox1
.ColumnCount = 2
'Me.ComboBox1.AddItem Plan1.Range("A" & i)
.List = lastRow.Cells.Value
End With
iForsta = 0
iSista = ComboBox1.ListCount - 1
For i = iForsta To iSista - 1
For j = i + 1 To iSista
If ComboBox1.List(i, sCol) > ComboBox1.List(j, sCol) Then
sTemp = ComboBox1.List(j, sCol)
ComboBox1.List(j, sCol) = ComboBox1.List(i, sCol)
ComboBox1.List(i, sCol) = sTemp
End If
Next j
Next i
End Sub
Como integrar os dois?
Abs.