
Use a user-defined function to sum all cells
with a shaded font
As learned from the previous tip, it is quite easy to sum up cells
that are shaded. Here we will sum up all cells formatted with the
font color blue. Use the worksheet from the previous tip, changing
the font style of two values to the color blue. Create a new
user-defined function as described below.
4
To sum all cells with a particular font color:
1. Press <Alt+F11> to open the Visual Basic Editor.
2. From the Insert menu, click Module.
3. Type the following function:
Function SumColorF(Area As Range, Ci As Integer)
Dim sng As Single, rng As Range
For Each rng In Area
If rng.Font.ColorIndex ...