Microsoft Office Tutorials and References
In Depth Information
Learning about Macros and VBA
Learning about Macros and VBA
The terms macro and VBA remain a mystery to most Excel users. This tip provides a broad
overview to help you decide whether learning to create Excel macros would be useful.
What is a macro?
A macro is a sequence of instructions that automates some aspect of Excel so that you can work
more efficiently and with fewer errors. You use the scripting language Visual Basic for
Applications (VBA) to create macros. You might create a macro, for example, to import data
from a text file, format it, and save it as a workbook. After the macro is developed, you can then
execute the macro to perform many time-consuming procedures automatically.
You need not be a power user to create and use simple VBA macros. Casual users can simply
turn on the Excel macro recorder: Excel records your actions and converts them into a VBA
macro. When you execute this macro, Excel performs the actions again.
More advanced users can write code that tells Excel to perform tasks that can’t be recorded. For
example, you can write procedures that display custom dialog boxes, add new commands to the
Excel menus, or process data in a series of workbooks.
What can a macro do?
VBA is an extremely rich programming language with thousands of uses. The following list
describes just a few things you can do with VBA macros:
h Insert a text string or formula: If you need to enter your company name into worksheets
frequently, you can create a macro to do the typing (and even format the cell) for you.
The Excel AutoCorrect feature can insert text, but it can’t do any formatting.
h Automate a procedure that you perform frequently: For example, you might need to
prepare a month-end summary. If the task is straightforward, you can develop a macro to
do it for you.
h Automate repetitive operations: If you need to perform the same action in 12 different
workbooks, you can record a macro while you perform the task once — and then let the
macro repeat your action in the other workbooks.
h Create a custom command: For example, you can combine several Excel commands so
that they’re executed from a single keystroke or from a single mouse click.
h Create a custom button: You can customize the Excel Ribbon or Quick Access toolbar
with your own buttons to execute macros that you write.
Search JabSto ::

Custom Search