Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao Domenico,
grazie per il vostro interessamento. Probabilmente non sono stato chiaro nell'esposizione del problema.
Quando ho parlato di array, intendevo l'utilizzo di un codice vba che mi restituisse un array ordinato per nominativo.
Tale array sarà poi sfruttato sempre tramite codice per ulteriori necessità.
Es:
sub testo
....
mArr=range ("B4:F7")
...ordinamento secondo col B ????
Prova la seguente UDF Foo:
'=========>>
Option Explicit
'--------->>
Public Function Foo(R) As Variant
Dim arrIn As Variant
Dim UB As Long
arrIn = R.Value
UB = UBound(arrIn)
QuickSort arrIn, 1, 1, UB, True
Foo = arrIn
End Function
'--------->>
Public Sub QuickSort(SortArray, col, L, R, bAscending)
'\ TomOgilvy: http://goo.gl/ninpZW
'Originally Posted by Jim Rech 10/20/98 Excel.Programming
'Modified to sort on first column of a two dimensional array
'Modified to handle a second dimension greater than 1 (or zero)
'Modified to do Ascending or Descending
Dim i, j, X, Y, mm
i = L
j = R
X = SortArray((L + R) / 2, col)
If bAscending Then
While (i <= j)
While (SortArray(i, col) < X And i < R)
i = i + 1
Wend
While (X < SortArray(j, col) And j > L)
j = j - 1
Wend
If (i <= j) Then
For mm = LBound(SortArray, 2) To UBound(SortArray, 2)
Y = SortArray(i, mm)
SortArray(i, mm) = SortArray(j, mm)
SortArray(j, mm) = Y
Next mm
i = i + 1
j = j - 1
End If
Wend
Else
While (i <= j)
While (SortArray(i, col) > X And i < R)
i = i + 1
Wend
While (X > SortArray(j, col) And j > L)
j = j - 1
Wend
If (i <= j) Then
For mm = LBound(SortArray, 2) To UBound(SortArray, 2)
Y = SortArray(i, mm)
SortArray(i, mm) = SortArray(j, mm)
SortArray(j, mm) = Y
Next mm
i = i + 1
j = j - 1
End If
Wend
End If
If (L < j) Then Call QuickSort(SortArray, col, L, j, bAscending)
If (i < R) Then Call QuickSort(SortArray, col, i, R, bAscending)
End Sub
'<<=========
La UDF Foo rappresenta una funzione matriciale che deve essere confermata con CTRL+MAISC+INVIO
Potresti scaricare il mio file di prova Domenico20200413.xlsm
===
Regards,
Norman