How to Count Color Cells in Excel- Step by Step Tutorial
Have you ever got into situation in office where you need to count the cells in Excel sheet with specific color? If yes then you can use following code which counts the number of cells with specific color (here it is yellow) and put the count in cell
How to Count Colored Cells in Excel
It is worth to mention that the above code does not count the cells where colors are coming through conditional formatting. You can use DisplayFormat.Interior.Color to get the conditional formatting colors (DisplayFormat.Interior.Color works only on Excel 2010 or above) or read this post

Public Function CountColorCells(rng As Range) As Long
'Variable declaration
Dim lColorCounter As Long
Dim rngCell As Range
'loop throught each cell in the range
For Each rngCell In rng
'Checking Yellor color
If Cells(rngCell.Row, rngCell.Column).Interior.Color = RGB(255, 255, 0) Then
lColorCounter = lColorCounter + 1
End If
Next
'Return the value
CountColorCells = lColorCounter
End FunctionTo use this code in your Excel file, follow below steps:
- Open the Excel file where you want to count the color cells
- Press Alt+F11
- Insert a Module (Insert>Module) from menu bar
- Paste the code in the module
- Now type the formula in the cell where you want to get the count
- =CountColorCells(A2:A11)
- Done
Here I have counted the cells with yellow color. You can change RGB (#,#,#) code to count other colors. You can find RGB codes of any color using following steps
- Select the cell which contain the color you want to count

- Right click and select ‘Format Cells…

- In the Format Cells dialog box go to ‘Fill’ tab and click on ‘More Colors…

That’s all, in the ‘Color’ dialog box, you can view the RGB (Red, Green, Blue) codes of the color

If you are look for a code to sum the cells based on it’s color then you can read this post.
How to Count Colored Cells in Excel
In this tutorial, I will show you three ways to count colored cells in Excel (with and without VBA):
- Using Filter and SUBTOTAL function
- Using GET.CELL function
- Using a Custom Function created using VBA






It doesn’t work with conditional formatting because the cell color does not really change
This code does not work with conditional formatting however we made it work. So please read below article to count colored cells with conditional formatting.
Count Colored Cells with Conditional Formatting
Hope you like the article. Please comment if you liked the solution. 🙂
Happy Reading!
Great tips! I always struggled with counting colored cells in Excel, but your step-by-step guide made it so easy to follow. Thanks for sharing!
Thanks.
Great tips! I never knew counting colored cells could be so straightforward with Excel. Thanks for breaking it down step by step!
Thank you for the feedback. Keep learning 🙂
Thank you for this detailed guide! Counting colored cells in Excel always seemed tricky to me, but your step-by-step instructions made it much easier to understand. I can’t wait to try it out in my own spreadsheets!
Thank you so much for your feedback. Keep learning 🙂
Great tips! I never realized how easy it is to count colored cells in Excel. The step-by-step instructions were really helpful. Thanks, ExcelSirJi!
Thank you for your feedback, keep learning 🙂
Great tips! I never knew counting colored cells could be so straightforward. The step-by-step guide made it easy to follow. Thanks, ExcelSirJi!
Thank you for the feedback.
This post is incredibly helpful! I never knew there were so many ways to count colored cells in Excel. Thank you for sharing these tips, especially the formula and the VBA method. Can’t wait to try them out in my projects!
thanks
Great tips! I never knew about the COUNTIF function for counting colored cells. This will definitely help in my data analysis tasks. Thanks, ExcelSirJi!
Thanks
This post was incredibly helpful! I never knew there was a way to count colored cells in Excel without using complicated formulas. The step-by-step guide made it so easy to follow. Thanks, ExcelSirJi!
Great post! I never knew counting color-coded cells could be this straightforward. The step-by-step instructions were really clear and easy to follow. Thank you, ExcelSirJi, for clearing up the confusion!
Thank you so much for the details.
VBA for something this basic is such a pain. Just use conditional formatting and filter by color instead of dealing with the script.
Everything just depends on the need.