-
-
Notifications
You must be signed in to change notification settings - Fork 0
Custom functions to get a cell's background color, font color and color code
Here you will find a summary of all the functions we've used in this example as well as a couple of new ones that retrieve color codes.
Note: Please remember that all of these formulas will work only if you have added the user-defined function to your Excel workbook as demonstrated earlier in the article.
-
CountCellsByColor(range, color code)- counts cells with the specified background color. In the above example, we used the following formula to count cells by color =CountCellsByColor(F2:F14,A17) where F2:F14 is the selected range and A17 is the cell with the needed background color. You can use all other formulas listed below in a similar way.
-
CountCellsByFontColor(range, color code) - counts cells with the specified font color.
- SumCellsByColor(range, color code) - calculates the sum of cells with a certain background color.
- SumCellsByFontColor(range, color code) - calculates the sum of cells with a certain font color.
- GetCellFontColor(cell) - returns the color code of the font color of a specified cell.
- GetCellColor(cell) - returns the color code of the background color of a specified cell.
Well, counting cells based on color and getting the sum of colored cells was pretty easy, wasn't it? Of course if you have that little VBA gem that makes the magic happen : ) But what if you do not color cells manually and rather use conditional formatting.