Se la sequenza di ordinamento è sempre la stessa
es.
A, F, P
oppure
F, A, P
oppure
P, A, F
(volendo puoi cambiare la sequenza agendo sulla macro puoi usare questo codice da inserire nel foglio, non nel modulo
- Codice: Seleziona tutto
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
CheckAreaA = "A1"
CheckAreaF = "F1"
CheckAreaP = "P1"
Application.ScreenUpdating = False
Application.Calculation = xlManual
If Not Application.Intersect(Target, Range(CheckAreaA)) Is Nothing Then
URG = Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(50, 1), Cells(URG, 16)).Select
Selection.Sort Key1:=Cells(51, 1), Order1:=xlAscending, Key2:=Cells(51, 6) _
, Order2:=xlAscending, Key3:=Cells(51, 16), Order3:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
Range("A1").Select
End If
If Not Application.Intersect(Target, Range(CheckAreaF)) Is Nothing Then
URG = Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(50, 1), Cells(URG, 16)).Select
Selection.Sort Key1:=Cells(51, 6), Order1:=xlAscending, Key2:=Cells(51, 1) _
, Order2:=xlAscending, Key3:=Cells(51, 16), Order3:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
Range("A1").Select
End If
If Not Application.Intersect(Target, Range(CheckAreaP)) Is Nothing Then
URG = Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(50, 1), Cells(URG, 16)).Select
Selection.Sort Key1:=Cells(51, 16), Order1:=xlAscending, Key2:=Cells(51, 1) _
, Order2:=xlAscending, Key3:=Cells(51, 6) _
, Order3:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
Range("A1").Select
End If
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Ora è sufficiente che clicchi due volte consecutive nella cella A1, F1 o P1
(selezione che puoi cambiare agendo sul checkareaA, ..F, ..P inserendo la riga 50)
Fai sapere
Ciao