
Use a custom function to shade all cells
containing formulas
The remaining tips in this chapter describe the usage of Visual
Basic Application (VBA) macros to enhance and optimize Excel
worksheets. For the first example, we’ll write a macro that shades
all cells containing formulas.
4
To shade all cells with formulas:
1. Press <Alt+F11> to open the Visual Basic Editor.
2. On the Insert menu, click Module.
3. Type the following macro:
Sub ColorThem()
Selection.SpecialCells (xlCellTypeFormulas).Select
With Selection.Interior
.ColorIndex = 44
.Pattern = xlSolid
End With
End Sub
4. From the Excel Tools menu, select Macro | Macros.
5. Select the ColorThem macro and ...