这样实现了
Sub 自定义排序()
Dim arr, i&
'设置自定义排序的顺序
arr = Array("院校", "层次", "地区/城市", "类型", "性质", "排名", "专业录取概率", "专业代码", "计划", "学费", "学制", "最低位次")
x = InputBox("请在b--m之间选择要排序的列号", "排序")
If x > "a" Then
With Application
.ScreenUpdating = False
.AddCustomList ListArray:=arr
i = .GetCustomListNum(arr)
'x = Selection.Column '用鼠标所在的列排序
'设置排序的区域,不把序号列纳入排序范围
With Range("B2" & ":m" & Range("A65536").End(xlUp).Row)
'设置排序的起始单元格,即当前鼠标的位置
.Sort Key1:=Columns(x), Order1:=xlAscending, Header:=xlNo, OrderCustom:=i + 1, SortMethod:=xlPinYin, DataOption1:=xlSortNormal
End With
.DeleteCustomList ListNum:=i
.ScreenUpdating = True
MsgBox "排序完成", vbInformation
End With
Else
MsgBox "不能选择b--m之外的列"
End If
End Sub
|