运行 VBA 来自热键的宏
Run VBA macro from a hotkey
我有这个宏可以格式化我的 Excel sheet。它更改顶行的颜色并添加过滤器、冻结窗格等。
我有一个个人工作簿,我将它保存到其中,因此我可以在我打开的任何 Excel 文件中使用它。
如果我 运行 来自开发人员选项卡的宏,它会起作用。如果我尝试 运行 使用热键将其设置为无效。
当我使用热键时唯一有用的是它会在第一行添加一个过滤器。
Sub FormatSheet()
'
' FormatSheet Macro
'
' Keyboard Shortcut: Ctrl+Shift+L
Worksheets(1).Select
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.349986266670736
.PatternTintAndShade = 0
End With
Selection.AutoFilter
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With
ActiveWindow.FreezePanes = True
Cells.Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Cells.EntireColumn.AutoFit
End Sub
你设置热键了吗?打开您的宏 (Alt+f8) 转到选项(针对该宏)并设置您的 ctrl+shift+L。
此外,命名模块会删除所有热键功能。
我有这个宏可以格式化我的 Excel sheet。它更改顶行的颜色并添加过滤器、冻结窗格等。
我有一个个人工作簿,我将它保存到其中,因此我可以在我打开的任何 Excel 文件中使用它。
如果我 运行 来自开发人员选项卡的宏,它会起作用。如果我尝试 运行 使用热键将其设置为无效。
当我使用热键时唯一有用的是它会在第一行添加一个过滤器。
Sub FormatSheet()
'
' FormatSheet Macro
'
' Keyboard Shortcut: Ctrl+Shift+L
Worksheets(1).Select
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.349986266670736
.PatternTintAndShade = 0
End With
Selection.AutoFilter
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With
ActiveWindow.FreezePanes = True
Cells.Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Cells.EntireColumn.AutoFit
End Sub
你设置热键了吗?打开您的宏 (Alt+f8) 转到选项(针对该宏)并设置您的 ctrl+shift+L。 此外,命名模块会删除所有热键功能。