Thank you all for your valuable feedback. Here is the resulting macro (written with a little help of the macro editor):
Sub RefreshAndSortData()
'
' RefreshAndSortData Macro
' Macro recorded and edited 17/03/2004 by Pietro Braione
'
'
With Worksheets("Studenti")
Worksheets("Studenti").QueryTables("iscritti").Refresh BackgroundQuery:=False
Worksheets("Studenti").QueryTables("iscritti").ResultRange.Sort Key1:=.Range("C1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Worksheets("Studenti").Range("C:E").Copy Destination:=.Range("L:N")
Worksheets("Studenti").Range("L:N").Sort Key1:=.Range("M1"), Order1:=xlAscending, _
Key2:=.Range("N1"), _
Order2:=xlAscending, Key3:=.Range("L1"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End With
End Sub
By now hooked to a new toolbar button, maybe in future I will hook it to a time trigger instead. Now I'm working on certifying it so I can keep macro security high.
Pietro