GOOGLE SHEETS: Counting Cells by Color and Returning a Value

I maintain a spreadsheet containing various dates, and I’ve applied conditional formatting to color these dates either Red or Green. I’m looking for a formula or script that can determine how many cells are colored Green within a defined range and then display this count in a specified cell. To summarize, I have three different groups of dates and need a solution that evaluates a chosen range of cells, counting the Green-colored ones, and subsequently outputs the total number of these Green cells into another defined cell.

hey, maybe u could try using Google App Script for that. Write a function to loop through ur range, & check background color of each cell using getBackground function. Count those that r green. It can directly update a cell with the count. hope tis helps :smiley:

In a similar situation, I used Google Sheets’ custom functions by utilizing a little workaround. While formulas alone don’t count cell colors, Google Apps Script can. Create a custom function by navigating to Extensions > Apps Script. You can write a script that loops through the specified range, checks each cell’s background color, and counts the ones that match the hexadecimal color code for Green. Return this count and call the function in your preferred cell. It’s relatively simple once you’re familiar with Apps Script.