How to Count Cells by Font Color in Excel

,

This post will guide you how to count cells by font color in Excel. How do I Count the number of cells with specific cell Font color by using a User Defined function in Excel.

1. Count Cells by Font Color

Assuming that you have a list of data in range B1:B9, in which contain some text or numeric values. and you want to count those cells based on Font color. How to accomplish it. You can use an User Defined function to count cells by font color in Excel. Just do the following steps:

Step1# open your excel workbook and then click on “Visual Basic” command under DEVELOPER Tab, or just press “ALT+F11” shortcut.

Get the position of the nth using excel vba1

Step2#  then the “Visual Basic Editor” window will appear.

Step3# click “Insert” ->”Module” to create a new module.

convert column number to letter3

Step4# paste the below VBA code into the code window. Then clicking “Save” button.

count cells by font color2
Function CountCellsByFontColor(rng As Range, Cell As Range)
Dim CellC As Range, ucoll As New Collection, i As Single
i = 0
For Each CellC In rng
    If CellC.Font.ColorIndex = Cell.Font.ColorIndex Then
        i = i + 1
    End If
Next CellC
    CountCellsByFontColor = i
End Function

#5 back to the current worksheet, then type the following formula in a blank cell, and then press Enter key. And drag the AutoFill Handle over to other cells.

=CountCellsByFontColor(B1:B9,D1)
count cells by font color1

This User Defined function will count how many times the font color in Cell C1 mathes each cell in range of cells B1:B9.

2. Video: Count Cells by Font Color

This Excel video tutorial on counting cells by font color. In this video, we’ll explore a powerful method using VBA code to count cells based on font color.

https://youtu.be/6kVM9xkI11E

Leave a Reply