The macrorecorder is not that smart. Apart from using Select all the time it also records all properties even though just one or two has been changed.
Since you start by clearing the format on the whole range you can delete all the formatting commands that just sets the values to their defaults.
The first bunch of lines looking like this:
Sub FormattingGlobal()
Application.EnableEvents = False
Application.ScreenUpdating = False
With ActiveSheet.Range("A1:K300")
.FormatConditions.Delete
End With
Range("A17:K190").Select
With Selection.Font
.Name = "Arial"
.Size = 9
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A17:A190").Select
With Selection.Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
could be changed into something like this:
Sub FormattingGlobal()
Dim x As Range
Application.EnableEvents = False
Application.ScreenUpdating = False
With ActiveSheet.Range("A1:K300")
.FormatConditions.Delete
End With
With Range("A17:K190")
With .Font
.Name = "Arial"
.Size = 9
End With
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
End With
Range("A17:A190").VerticalAlignment = xlCenter
Note also the dim x statement. That tells VBA that I'm gonna use a variable named x and that it will contain a range. This saves a little bit of memory and speeds things up just a little bit.
I haven't tested this code and I may have deleted some rows that were not the defaults but hopefully it will give you some leads anyway.
Bookmarks