PROJECT 7 CLASS NOTES
This week you are to work through Project 7, pgs.
EX 482-555
PROJECT OVERVIEW
This project introduces macros and Visual Basic for Applications (VBA)
with Excel.
Terminology:
functions
A pre-written formula that takes a value or values, performs an operation,
and returns a value or values. Use functions to simplify and shorten
formulas on a worksheet, especially those that perform lengthy or
complex calculations.
module
A collection of declarations, statements, and procedures
stored together as one named unit. There are two types of modules:
standard modules and class modules.
Visual Basic
A high-level, visual-programming version of Basic. Visual Basic was
developed by Microsoft for building Windows-based applications.
Visual Basic Editor
An environment in which you can edit macros that you've recorded and
write new macros and Visual Basic for Applications programs.
About macros
If you perform a task repeatedly in Microsoft Excel, you can automate
the task with a macro. A macro is a series of commands and functions
that are stored in a Microsoft Visual Basic module and can be run
whenever you need to perform the task.
For example, if you often enter long text strings in
cells, you can create a macro to format those cells so that the text
wraps.
Recording macros
When you record a macro, Excel stores information about each step
you take as you perform a series of commands. You then run the macro
to repeat, or "play back," the commands. If you make a mistake
when you record the macro, corrections you make are also recorded.
Visual Basic stores each macro in a new module attached to a workbook.
Making a macro easy to run You can run a macro by choosing
it from a list in the Macro dialog box. To make a macro run whenever
you click a particular button or press a particular key combination,
you can assign the macro to a toolbar button, a keyboard shortcut,
or a graphic object on a worksheet.
Managing your macros
After you record a macro, you can view the macro code with the Visual
Basic Editor to correct errors or change what the macro does. For
example, if you wanted the text-wrapping macro to also make the text
bold, you could record another macro to make a cell bold and then
copy the instructions from that macro to the text-wrapping macro.
The Visual Basic Editor is a program
designed to make writing and editing macro code easy for beginners,
and provides plenty of online Help. You don't have to learn how to
program or use the Visual Basic language to make simple changes to
your macros. With the Visual Basic Editor, you can edit macros, copy
macros from one module to another, copy macros between different workbooks,
rename the modules that store the macros, or rename the macros.
Macro security
Excel provides safeguards against viruses that can be transmitted
by macros. If you share macros with others, you can certify them with
a digital signature so that other users can verify that they are from
a trustworthy source. Whenever you open a workbook that contains macros,
you can verify their source before you enable them.
Macro Security
The following information summarizes how macro virus
protection works under each setting on the Security Level tab in the
Security dialog box (Tools menu, Macro submenu) under different conditions.
Under all settings, if antivirus software that works with Microsoft
Office XP is installed and the file contains macros, the file is scanned
for known viruses before it is opened.
High
Unsigned macros. Macros are automatically disabled, and the
file is opened.
Medium
Unsigned macros. User is prompted to enable or disable macros.
Low
When security it set to low, all macros are treated equally
regardless of origin or certificate status. With low security, you
receive no prompt or signature validation and macros are automatically
enabled. Use this setting only if you are certain that all macros
in your files are from trusted sources.