Page 308 - Excel Progamming Weekend Crash Course
P. 308
r540629 ch22.qxd 9/2/03 9:35 AM Page 283
SESSION
22
A User Form Example
Session Checklist
✔ Planning the sample project
✔ Creating the workbook
✔ Designing the form
✔ Writing the code
✔ Validating data
✔ Testing the project
Planning the Project
This example of an Excel program that uses a user form to assist the user in entering data
is something that you might want to do in the real world. Of course, the user could always
enter data directly into a worksheet, so why bother creating a program and a user form for
the purpose? There are several reasons:
User fatigue. Staring at a grid of worksheet rows and columns for extended periods
can induce fatigue and increase the chance of errors. A nicely designed user form is
much easier on the eyes.
Greater accuracy. You can write code to ensure that each item of data is placed in
the proper location in the worksheet. Manual entry is much more prone to mistakes.
Data validation. Code in a user form can validate the data that was entered and
perform checks, such as verifying that a zip code, for example, contains five digits
and nothing more (or, in the case of the newer codes, nine digits and a dash). It’s
much easier to catch bad data before it is entered than to deal with it later.

