Codice: Seleziona tutto
Sub ordina 'bubblesort
Set Dic = CreateObject("Scripting.Dictionary")
REM Si carica la libreria Tools per accedere alla funzione BubbleSortList
If (Not GlobalScope.BasicLibraries.isLibraryLoaded("Tools")) Then
GlobalScope.BasicLibraries.LoadLibrary("Tools")
End if
sh = thiscomponent.Sheets(0)
r= 2
do
v = sh.GetCellRangeByName("A" & r).String
if v = "" then exit do
If Dic.Exists(v) = False Then
Dic.Add v, 0
end if
r= r + 1
Loop
iF Dic.count > 0 Then
n = Dic.count-1
Redim lista(0 To n)
For i = 0 To n
lista(i) = Dic.Keys()(i)
Next i
lista() = BubbleSortList(lista)
Dim arr(1 to n+1, 1 To 1) ' <<<< da evitare
For i = 0 To n
arr(i+1, 1) = lista(i)
Next i
CellRange = Sh.getCellRangeByName("C1:C" & n+1)
CellRange.SetDataArray(arr)
end if
End sub