Count Cells by Colour

Peter Davison

Active Member
Joined
Jun 4, 2020
Messages
451
Office Version
  1. 365
Platform
  1. Windows
Is it possible to count cells by colour in Excel?
I read on a website is wasn't possible unless the code below was added.

Do you feel this is possible?
I am on 365
Thanks for your help

Function CountCellsByColor(data_range As Range, cell_color As Range) As Long
Dim indRefColor As Long
Dim cellCurrent As Range
Dim cntRes As Long
Application.Volatile
cntRes = 0
indRefColor = cell_color.Cells(1, 1).Interior.Color
For Each cellCurrent In data_range
If indRefColor = cellCurrent.Interior.Color
Then
cntRes = cntRes + 1
End If
Next cellCurrent
CountCellsByColor = cntRes
End Function
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Sorry if I have misled you.
I'm not too familiar with this type of counting.
Where in the conditional formatting does it allow me to count?

I watched a video after your message and the person said use - =countconditioncolorcells(range,colorcell)
But when I type that in I don't have that formula option.

So any further help would be appreciated.
Thank you
 
Upvote 0
You just use a formula in the sheet that counts how many cells match the conditional formatting rule.
 
Upvote 0
So would that be a countif?
I'm trying to find out the number of cells in I21:I5000 that don't equal the same cells in H21:h5000
I am so sorry to be a pain and you've been so patient and helpful.

It would be great in a future release of Excel if that had a simple count color cells.
 
Upvote 0
It would be great in a future release of Excel if that had a simple count color cells.
I would have to disagree, colour is not data & should not be used as such.
Try
Excel Formula:
=SUM(--(I2:I5000<>H2:H5000))
 
Upvote 0
I got there and thanks all to you.
I really appreciate your time and help.
Maybe one day I will get just 10% of your knowledge.
Thanks again.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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