

The function will sum in this example because you used TRUE as the last argument for the custom function. To sum the values in the range of cells $A$1:$A$12 that have the same fill color as cell $C$1.

Now you can use the custom function ColorFunction in formulas such as this: =ColorFunction($C$1,$A$1:$A$12,TRUE) VResult = WorksheetFunction.SUM(rCell) + vResult In this module, type the following code: Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean) Go into the VBE by selecting Tools » Macro » Visual Basic Editor (Alt/Option-F11) and then select Insert » Module to insert a standard module. To do this, first open the workbook where you want to COUNT or SUM cells by a fill color. You can also get quick calculations of Averages, Minimums and Maximums in the status bar.Every now and then, it's convenient to SUM or COUNT cells that have a specified fill color that you or another user have set manually, as users often understand paint colors more readily than named ranges. Ever wanted to get a quick sum or count of highlighted cells in Excel without creating a formula? Change the status bar to show Count and Sum.

(Text imported from WordPerfect often embeds random section breaks into a document, which can affect the headers and footers.) How much time would you have otherwise spent trying to troubleshoot that problem? Why? The status bar gives you a clue: the section numbers at the left keep changing.
