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

Microsoft Office Excel 2003 Programming Inside Out

                                         .PatternColorIndex = xlAutomatic
                                      End With
                                      ActiveCell.Offset(0, 1).Formula = NumColor
                                      ActiveCell.Offset(1, 0).Activate
                                   Next NumColor
                             End Sub

                             Caution  A version of this procedure was originally published on the Microsoft Knowledge
                             Base at http://support.microsoft.com/support/kb/articles/q149/1/70.asp, but that ver­
                             sion of the program has a variable naming error that causes it to repeat the same color in
                             all 56 cells. For debugging practice, run the code, find out what happens, and see if you can
                             spot the error (provided the MSDN folks haven’t corrected it).

                             But what if the colors in the palette aren’t what you need for your designs? Many organiza­
                             tions have policies regarding the specific colors used in and appearance of their logos and
                             official documents. Rather than be forced to work with colors that might not be exactly right,
                             you can substitute a custom color for an existing color in the palette.
                             To assign a new color to a slot in the Excel color palette from within the Excel program, follow
                             these steps:
                               1  Click Tools, Options, and then click the Color tab in the Options dialog box.











             Chapter 10













                               2	 Click the square of the color you want to replace, and then click Modify. If you see the
                                  color you want in the Colors dialog box that appears, click it and then click OK. If you
                                  don’t see the color you want, click the Custom tab.
                               3  Verify that RGB is selected in the Color Model list box.
                               4  Type the red, blue, and green components of your color in the appropriate boxes.




                224
             Part 4:  Advanced VBA
   245   246   247   248   249   250   251   252   253   254   255