Get Count of Cells based on Color Excel Add-in using VBA

Get Count of Cells based on Color Excel Add-in using VBA

Cells Color

If you have lots of data bifurcated using colors, this post will help you to get quick analysis done over the data based on color. In this article we will write a user defined function which get count of cells based on color using VBA.

Input Data

Code example

Public Function Get_Color_Count(range_data As Range, oCriteria As Range) As Long
Dim oData As Range
Dim oColor As Long
oColor = oCriteria.Interior.ColorIndex
    For Each oData In range_data
        If oData.Interior.ColorIndex = oColor Then
            Get_Color_Count = Get_Color_Count + 1
        End If
    Next oData
'CleanUp
If Not range_data Is Nothing Then
    Set range_data = Nothing
End If
End Function

Implementation

Output

Next >> TRUNC Function or TRUNC Formula in Excel with example

Leave a Reply

Your email address will not be published. Required fields are marked *