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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,224,752
Messages
6,180,743
Members
452,996
Latest member
nelsonsix66

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