Page 197 - Excel Progamming Weekend Crash Course
P. 197
k540629 ch14.qxd 9/2/03 9:34 AM Page 172
172 Saturday Afternoon
Border. This is where you can specify the style and placement of borders around the
cell edges.
Patterns. This determines the color and pattern of the cell background.
Protection. This locks and hides cells.
Figure 14-1 The Format Cells dialog box has a separate
tab for each category of cell formatting.
Changing cell formatting in a VBA program requires that you obtain a range reference to
the cell(s) of interest and then use the Range object’s properties to set the desired format-
ting. These properties are covered in detail in the following sections. Be aware, however,
that Excel’s formatting capabilities are very sophisticated and complete, and it is beyond
the scope of this book to go into detail on more than a small fraction of the possibilities.
For this reason, I have the following two suggestions:
Work in Excel to become familiar with the formatting options that are available to
you. Explore the various settings in the Format Cells dialog box, as well as the other
commands on the Format menu. Use the online help as needed for clarification and
assistance.
Use the macro-recording feature to learn about the code required to apply specific
formatting.
See Session 10 for more information on defining ranges. The steps required
to record a macro were presented in Session 2.
Cross-Ref
When using the macro-recording feature, be aware of the way that Excel records macros.
If you record the actions of using the Format Cells dialog box to change one aspect of for-
matting, the macro includes not only the aspect(s) of formatting that you changed, but also
those aspects that were not changed. Here’s an example. I recorded the action of changing