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
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 Function
To use this code in your Excel file, follow below steps:
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
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.
In this tutorial, I will show you threeΒ ways to count colored cells in Excel (with and without VBA):
This tutorial shows you how to change the row colors in Excel to automatically highlight every other row or every nth row or column in your worksheets. You will also learn how to use Excel’s banded rows and columns and find some helpful formulas to shade rows based on value changes.
Using alternating colors for rows in Excel is a common way to make data easier to read. While itβs simple to manually highlight rows in a small table, it can be very time-consuming in larger tables. A better approach is to automatically alternate the colors of rows or columns, and this article will show you how to do it quickly
Understand how to find median in Excel with simple steps. Understanding the middle value in a set of numbers, known as the median, is important in the data industry. Professionals often use Microsoft Excel to calculate this. Excel’s MEDIAN function helps quickly find this value from long lists of numbers. This saves time and allows for further calculations using the median value. In this article, we explain what the MEDIAN function in Excel does, why it’s useful, and two methods to find the median in your data.
Undo in excel very useful If you’re new to Excel or even if you’ve been using it for a while, you’ve probably made a mistake on a spreadsheet. Mistakes happen a lot, especially when working…
In this tutorial, we’ll learn how to convert inches to Centimeters, and millimeters. A millimeters is one-tenth of a centimeter. You can easily do these conversions in Excel using formulas. Letβs see how it works.
Add new line in Excel cell lets you type on multiple lines within the same cell. Instead of having all the text in one long line, you can split it up to make it easier…
Excel has built-in options to make graphs, it doesn’t have a heat map feature. However, you can quickly and easily create a heat map in Excel using conditional formatting.
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 π