- I am having trouble condensing this code down using "With" statements. Below is my following code. Can someone help me with this situation?
Sub FormatMacro()
Range("H1:H2").NumberFormat = "0.00000"
Range("H1:H2").NumberFormat = "0.0000"
Range("H1:H2").NumberFormat = "0.000"
Range("H1:H2").NumberFormat = "0.00"
Range("H1:H2").HorizontalAlignment = xlCenter
Range("H1:H2").VerticalAlignment = xlBottom
Range("H1:H2").WrapText = False
Range("H1:H2").Orientation = 0
Range("H1:H2").AddIndent = False
Range("H1:H2").IndentLevel = 0
Range("H1:H2").ShrinkToFit = False
Range("H1:H2").ReadingOrder = xlContext
Range("H1:H2").MergeCells = False
Range("H1:H2").Font.Bold = True
Range("H1:H2").Font.Name = "Andalus"
Range("H1:H2").Font.Size = 11
Range("H1:H2").Font.Strikethrough = False
Range("H1:H2").Font.Superscript = False
Range("H1:H2").Font.Subscript = False
Range("H1:H2").Font.OutlineFont = False
Range("H1:H2").Font.Shadow = False
Range("H1:H2").Font.Underline = xlUnderlineStyleNone
Range("H1:H2").Font.ThemeColor = xlThemeColorLight1
Range("H1:H2").Font.TintAndShade = 0
Range("H1:H2").Font.ThemeFont = xlThemeFontNone
End Sub
CodePudding user response:
with Range("H1:H2")
.NumberFormat = ...
.
. Here you put everything except Font part
.
with .Font
.Size = ...
...
end with
end with