Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

MACROS

Microsoft Excel

What is a Macro?
A

macro is a set of instructions that


tells Excel what to do. These
commands are written in a
computer programming language
called Visual Basic Applications
(VBA).
A macro is also referred as
Procedures.

Just

as a tape recorder can be used


to record sounds which can be
played back later, so as the Macro
Recorder can record actions into a
macro. These macros can be run
whenever you wish, automatically
repeating your recorded actions and
so saving your time and effort.

There

are two ways to create a


macro: You can record it or you
can build it by entering
instructions in a module. Either
way, your instructions are encoded in
the programming language
Microsoft Visual Basic for
Applications (VBA).

In

naming a macro,

The first character of the macro must be


a LETTER.
The following characters can be letters,
numbers, or underscore characters.
Spaces are not allowed in a macro
name; use an underscore character ( _ )
as word separator.

VBA Environment

Each time you record a macro, the macro


is stored in a module attached to a
workbook. Recorded macros can be stored
in This Workbook, New Workbook,
and Personal Workbook.

What is Excel VBA?


VBA stands for Visual Basic for
Applications. It's a programming language
that enables you to control just about
everything in Excel.

VBA Environment
The

first and last lines of the code


act as the beginning and
endpoints for the macro youve
recorded.
A Sub statement starts the macro
End Sub statement ends the
macro.

Special

VBA terms, also called


keywords are displayed in dark
blue.
SUB this is a keyword that begins a
Macro and is followed by the name of
the macro.
COMMENTS- the comments are
entered following an apostrophe. VB
ignores the apostrophe.

STATEMENTS-

Each action
carried out by the Macro is
written in statements. The
syntax of a statement is an
Object followed by the Action
END SUB- This is a keyword that
ends the Macro.

You might also like