Wiley Excel 2003 VBA Programmer's Reference 978-0-7645-5660-9 Benutzerhandbuch

Produktcode
978-0-7645-5660-9
Seite von 62
P1: IML/FFX
P2: IML/FFX
QC: IML/FFX
T1: IML
WY010-01
WY010-Kingsley WY010-Kimmel-v1.cls
June 10, 2004
22:23
Primer in Excel VBA
This chapter is intended for those who are not familiar with Excel and the Excel macro recorder, or
who are inexperienced with programming using the Visual Basic for Applications (VBA) language.
If you are already comfortable with navigating around the features provided by Excel, have used
the macro recorder, and have a working knowledge of VBA and the Visual Basic Editor (VBE), you
might want to skip straight to Chapter 3.
If this is not the case, this chapter has been designed to provide you with the information you need
to be able to move on comfortably to the more advanced features presented in the following
chapters. We will be covering the following topics:
The Excel macro recorder
User-defined functions
The Excel Object Model
VBA programming concepts
Excel VBA is a programming application that allows you to use Visual Basic code to run the many
features of the Excel package, thereby allowing you to customize your Excel applications. Units of
VBA code are often referred to as macros. We will be covering more formal terminology in this
chapter, but we will continue to use the term macro as a general way to refer to any VBA code.
In your day-to-day use of Excel, if you carry out the same sequence of commands repetitively, you
can save a lot of time and effort by automating those steps using macros. If you are setting up an
application for other users, who don’t know much about Excel, you can use macros to create buttons
and dialog boxes to guide them through your application as well as automate the processes
involved.
If you are able to perform an operation manually, you can use the macro recorder to capture that
operation. This is a very quick and easy process and requires no prior knowledge of the VBA
language. Many Excel users record and run macros and feel no need to learn about VBA.
However, the recorded results might not be very flexible, in that the macro can only be used to carry
out one particular task on one particular range of cells. In addition, the recorded macro is likely
COPYRIGHTED MATERIAL