A formula to count the colors in excel sheet

MFT

New Member
Joined
Feb 14, 2023
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Dear All,

I require a formula to count the respective colours for each employee as below:

1678798518525.png
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi,
As long as each color has its pre-defined letter or symbol, it will be easier for you to use Countif() with this unique identifier ...
 
Upvote 0
Hi James,

That I have put manually for convenience to count. However in the original file there are no letters or symbols.
 
Upvote 0
@*MFT, What are the rules that place the colors in those cells?

What we are saying is that there is not a formula that reads cell colors. If there is, it is something I am not aware of.
 
Upvote 0
You can't count color in excel. Just put some letter in it then use Countif
 
Upvote 0
Hello again,

To count colors, you can adapt following UDF
VBA Code:
Function mycount(rng As Range)
'Example for Red =mycount(C10:AG10)
Dim c As Range, counter As Long
    For Each c In rng
        If c.Interior.Color = 255 Then counter = counter + 1
    Next c
 mycount = counter
End Function
 
Upvote 0
Version 2 ...
VBA Code:
Function mycount(rng As Range, mycolor As Range)
' Version 2 for all colors
' Example for Cell E16 =mycount($C10:$AG10,E$15)
Dim c As Range, counter As Long
    For Each c In rng
        If c.Interior.Color = mycolor.Interior.Color Then counter = counter + 1
    Next c
 mycount = counter
End Function
 
Upvote 0

Forum statistics

Threads
1,223,882
Messages
6,175,164
Members
452,615
Latest member
bogeys2birdies

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