ecco una possibile soluzione al tuo problema.
Calcola le prime sei maggiori ricorrenze in un range di dati.
Copia questa macro in un modulo di Visual basic.
La macro considera i dati in colonna "A" del foglio1 e necessita di spazio libero sulla colonna "A" del foglio2 per appoggiare i dati.
questa è la macro:
Sub moda()
Application.ScreenUpdating = False
Sheets("foglio1").Select
Set miorange = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
miorange.Select
Selection.Copy
Sheets("foglio2").Select
Range("a1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Set miorage = Nothing
Set area = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
r = Range(Cells(1, 1), Cells(1, 1).End(xlDown)).Rows.Count
r1 = Application.Mode(area)
For n = r To 1 Step -1
Range("a" & n).Select
If ActiveCell = r1 Then
ActiveCell.EntireRow.Select
Selection.Delete
End If
Next
r2 = Application.Mode(area)
For n = r To 1 Step -1
Range("a" & n).Select
If ActiveCell = r2 Then
ActiveCell.EntireRow.Select
Selection.Delete
End If
Next
r3 = Application.Mode(area)
For n = r To 1 Step -1
Range("a" & n).Select
If ActiveCell = r3 Then
ActiveCell.EntireRow.Select
Selection.Delete
End If
Next
r4 = Application.Mode(area)
For n = r To 1 Step -1
Range("a" & n).Select
If ActiveCell = r4 Then
ActiveCell.EntireRow.Select
Selection.Delete
End If
Next
r5 = Application.Mode(area)
For n = r To 1 Step -1
Range("a" & n).Select
If ActiveCell = r5 Then
ActiveCell.EntireRow.Select
Selection.Delete
End If
Next
r6 = Application.Mode(area)
For n = r To 1 Step -1
Range("a" & n).Select
If ActiveCell = r6 Then
ActiveCell.EntireRow.Select
Selection.Delete
End If
Next
Set area = Nothing
Cells.Select
Selection.ClearContents
Range("a1").Select
Sheets("foglio1").Select
Range("b1") = r1
Range("c1") = "1° in frequenza"
Range("b2") = r2
Range("c2") = "2° in frequenza"
Range("b3") = r3
Range("c3") = "3° in frequenza"
Range("b4") = r4
Range("c4") = "4° in frequenza"
Range("b5") = r5
Range("c5") = "5° in frequenza"
Range("b6") = r6
Range("c6") = "6° in frequenza"
Range("a1").Select
Application.ScreenUpdating = True
End Sub
vedi se è quanto ti è utile.
saluti
Andrea
Edited by - a10n11 on 07/25/2005 12:01:11