I have this macro that formats my Excel sheet. It changes the color of the top row and adds a filter, freezes pane, etc.
I have a personal workbook I saved it to, so I can use it in any Excel file I open.
It works if I run the macro from the developer tab. If I try running it using a hotkey it does not work.
The only thing that works when I use the hotkey is it will add a filter to the top row.
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