Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim mnDirection As Integer
Dim mnColumn As Integer
If Target.Column < 5 And Target.Row = 1 Then
If Target.Column <> mnColumn Then
mnColumn = Target.Column
mnDirection = xlAscending
Else
If mnDirection = xlAscending Then
mnDirection = xlDescending
Else
mnDirection = xlAscending
End If
End If
Dim rg As Range
Set rg = Me.Cells(1, 1).CurrentRegion
rg.Sort Key1:=rg.Cells(1, mnColumn), _
Order1:=mnDirection, _
Header:=xlYes
Set rg = Nothing
End If
End Sub
|