Page 261 - Microsoft Office Excel 2003 Programming Inside Out
P. 261

Formatting Excel Objects

                             The array of patterns available to you, represented by the Excel constants in the Pattern prop­
                             erty’s description in the preceding table, are available for viewing by clicking Format, Cells,
                             clicking the Patterns tab, and clicking the Pattern down arrow.






























                             One important thing to know about the Color and ColorIndex properties is that they affect a
                             different aspect of the cell’s interior than do the PatternColor and PatternColorIndex proper-
                             ties. The default color for either the PatternColor or PatternColorIndex properties is black
                             (represented in the PatternColorIndex property as the index number 1), but you can change   Chapter 10
                             the color of the pattern.
                             The following procedure changes the fill color of the active cell to blue, adds a pattern of thin,
                             black, horizontal lines, and then changes the color of the fill pattern to white:

                             Sub ChangePattern()
                             With ActiveCell
                              .Interior.ColorIndex = 5
                              MsgBox (“OK to add the horizontal pattern?”)
                              .Interior.Pattern = xlPatternLightHorizontal
                              MsgBox (“OK to change the pattern’s color?”)
                              .Interior.PatternColorIndex = 2
                             End With
                             End Sub










                                                                                                       235
                                                                                                Part 4:  Advanced VBA
   256   257   258   259   260   261   262   263   264   265   266