这是我的代码。除了Sorter
之外,按下各自的键时,所有宏都可以工作。不确定为什么Handler
在按下键时没有调用宏。有什么想法吗?
Public Sub Workbook_Open()
Application.OnKey "^%{~}", "DailyStatusSorter"
End Sub
Public Sub DailyStatusSorter()
' DailyStatusSorter Macro
' Sorts Daily Staus buy completed, priority , then date from oldest to newest.
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Daily_Status").Sort.SortFields _
.Clear
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Daily_Status").Sort.SortFields _
.Add Key:=Range("Daily_Status[Last edited by]"), SortOn:=xlSortOnCellColor _
, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Daily_Status").Sort.SortFields _
.Add Key:=Range("Daily_Status[Priority]"), SortOn:=xlSortOnValues, Order _
:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Daily_Status").Sort.SortFields _
.Add Key:=Range("Daily_Status[Date]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").ListObjects("Daily_Status").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
答案 0 :(得分:0)
如果您想要Ctrl + Alt + Enter
组合,请从密钥中删除{}
:
Application.OnKey "^%~", "DailyStatusSorter"
如果您保留"^%{~}"
,则需要按Ctrl + Alt + Shift + ~
p.s。:将宏移动到独立的代码模块,而不是工作簿的代码模块