魔方网表 让信息化更简单

 找回密码
 注册
查看: 1780|回复: 0

一段可以双击列表题自动按双击列排序的代码,

[复制链接]
lnxxnchzyl 发表于 2009-10-19 09:55:28 | 显示全部楼层 |阅读模式
一段可以双击列表题自动按双击列排序的代码,
添加到工作表双击事件即可

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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|魔方软件 ( 京ICP备08008787号 )

京公网安备 11010702001722号

GMT+8, 2024-5-5 13:21 , Processed in 1.170846 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表