|
一段可以双击列表题自动按双击列排序的代码,
添加到工作表双击事件即可
Dim rg As Range
If Target.Column <= Me.Cells _(1,1).CurrentRegion.Columns.Count _
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
Set rg = Me.Cells(1, 1).CurrentRegion
rg.Sort key1:=rg.Cells(1, mnColumn), order1:=mnDirection, _ header:=xlYes
Set rg = Nothing
Cancel = True
End If |
|