Create a count of Cells of different colors

mv816700

New Member
Joined
Oct 21, 2021
Messages
10
I am attempting to count the number of cells in column A that are formatted with different colors (Green, Yellow, Blue, Orange, empty, etc.) and place the total in column M.

I have tried =countIf( ...) and many others.

Is there a Filter command I can use?

Any advice is welcome. I thought this would be an easy task. My bad

Thank you
Mike
 

Attachments

  • CountColoredCells (Medium).jpg
    CountColoredCells (Medium).jpg
    135.2 KB · Views: 20

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I have written my own function to do exactly this, you can use it just like any other excel macro in any workbook you install it in:
VBA Code:
Function SumByColor(CellColor As Range, rRange As Range)
Application.Volatile
Dim cSum As Double

Dim ColIndex As Integer
ColIndex = CellColor.Interior.ColorIndex
For Each cl In rRange
If cl.Interior.ColorIndex = ColIndex Then
cSum = WorksheetFunction.Sum(cl, cSum)
End If
Next cl
SumByColor = cSum
End Function

in use:
Excel Formula:
=sumbycolor($K2,$G$9:$G$65)
where K2 is a colored cell and G9 to G65 has some cells with the same color as K2
 
Upvote 0
I have just realised you wanted a count not the sum the function can be easily modifed :
VBA Code:
Function countByColor(CellColor As Range, rRange As Range)
Application.Volatile
Dim cSum As Double

Dim ColIndex As Integer
ColIndex = CellColor.Interior.ColorIndex
For Each cl In rRange
If cl.Interior.ColorIndex = ColIndex Then
cSum = cSum + 1
End If
Next cl
countByColor = cSum
End Function
 
Upvote 0
Wow. thx, I thought there was a way to do this using Excell. Nice thank you

but
How do I add this function? newbie to this.
 
Upvote 0

Forum statistics

Threads
1,223,710
Messages
6,174,017
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top