132 PCWorld MARCH 2020
HERE’S HOW HOW TO CREATE EXCEL MACROS
Select Range E13
With Selection (format as follows)
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection (format as follows)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub
Just like HTML and most other languages,
certain statements (or commands) that have
a beginning or open statement must also
have an ending statement.
To make changes, just type them in, then
click Alt+ Q to return to the spreadsheet.
Excel displays a dialog window that says: This
command will stop the Debugger. Just click
the OK button and the macro disappears.
If you make an editing mistake, exit, then
run the macro, Excel displays this error
message: Compile Error: Syntax Error.
Compile means “convert the code” to
whatever format is required to make this
program/macro function. Syntax just means
“sentence,” or basically, you have an error in
one of your command sentences.
Click the OK button, and Excel displays
the macro code on the screen. The location
of the error is in red, so you can go directly
to the mistake and fix it. Once repaired, the
red text will turn black. Then save it again;
Press Alt+ Q, run it again, and if the fix was
correct, the macro works.
Understanding macro error messages.