Uso a função abaixo para Classificar Setores Exclusivos e em Ordem Alfabética (coluna F da Planilha11).
Funciona mas é muito lento.
No frmEmpresas clique no Botão de Opção Setor.
Será que pode ser mais rápido?
Código: Selecionar todos
Private Sub SetorCombobox2()
SpeedUp
Dim Z As Integer
Dim iforsta, isista As Integer
Dim i, j As Integer
Dim stemp As String
ultimaLin = Planilha11.Cells(Rows.Count, "F").End(xlUp).Row
For Z = 2 To ultimaLin
ComboBox2 = Planilha11.Range("F" & Z)
If ComboBox2.ListIndex = -1 Then ComboBox2.AddItem Planilha11.Range("F" & Z)
Next Z
iforsta = 0
isista = ComboBox2.ListCount - 1
For i = iforsta To isista - 1
For j = i + 1 To isista
If ComboBox2.List(i) > ComboBox2.List(j) Then
stemp = ComboBox2.List(j)
ComboBox2.List(j) = ComboBox2.List(i)
ComboBox2.List(i) = stemp
End If
Next j
Next i
ResetConfig
End Sub