How To Count Highlighted Cells In Google Sheets

Table of Contents

Table of Contents

Counting highlighted cells can be useful when you’re working with color-coded data in Google Sheets. If you’re using colors to mark task status or track progress, it can be difficult to keep an accurate count just by looking at the sheet. Instead of manually going through each cell, you can use a few simple methods to count the colored cells automatically.

In this article, weโ€™ll show you how to count highlighted cells in Google Sheets using practical techniques that help organize your data and make analysis easier.

Key Takeaways

You can use the built-in COUNTIF function to count highlighted cells based on text values.

Hereโ€™s is an easy guide how to apply this method:

โžค Open your dataset in the Google sheets.
โžค Select an empty cell where you display the result of counting highlighted cells. For example, select cell F2 next to the label Not Started.
โžค Enter this formula =COUNTIF(C2:C11, E2)
โžค Click Enter. This will return the number of tasks marked as Not Started.
โžค To apply the same formula to the other rows, drag the fill handle from F2 down to F4 and the values will update automatically.

overview image

Download Practice Workbook
1

Using Apps Script to Count by Fill Color

In the following dataset, there is a single sheet with three main columns labeled Task, Assigned To, and Status. Each row represents a task assigned to a team member, with the Status column filled using color to indicate progress. Green is used for completed tasks, yellow for tasks in progress, and red for those not started.

To make it easier to count the colored cells, a small color key is included on the right side of the sheet. This section contains the three colors used in the Status column, along with an empty cell next to each one where the final count will be displayed.

Weโ€™ll use this setup to apply and practice different methods for counting highlighted cells in Google Sheets.

Using Apps Script to Count by Fill Color

You can use Apps Script method to count how many times a specific background color appears in your dataset. The script will check the Status column, compare each cell’s background color to a reference color, and return the total count.

Hereโ€™s a simple step-by-step guide to apply this method:

โžค Open your dataset in Google sheets.
โžค Go to the top Menu and click Extensions >> Apps Script.

Using Apps Script to Count by Fill Color

โžค The Apps Script editor will open in a new tab. Delete any code already in the editor.

Using Apps Script to Count by Fill Color

โžค Copy and paste the script below into the editor:

function countColoredCellsByReference() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const statusRange = sheet.getRange("C2:C11"); // Status column
const colorRefRange = sheet.getRange("E2:E4"); // Reference color cells
const countOutputRange = sheet.getRange("F2:F4"); // Where counts will go
const statusColors = statusRange.getBackgrounds();
const referenceColors = colorRefRange.getBackgrounds();
for (let i = 0; i < referenceColors.length; i++) {
let refColor = referenceColors[i][0];
let count = 0;
for (let j = 0; j < statusColors.length; j++) {
if (statusColors[j][0] === refColor) {
count++;
}
}
countOutputRange.getCell(i + 1, 1).setValue(count);
}
}

โžค Click the Save icon.

Using Apps Script to Count by Fill Color

โžค Once you save the script the Run option will activate.
โžค Click Run to execute the script.

Using Apps Script to Count by Fill Color

โžค Now, youโ€™ll see a message saying Execution started at the top of the editor.

Using Apps Script to Count by Fill Color

Note:
If this is your first time running the script, a prompt will appear asking you to review and grant permission. Click Continue to allow the execution.

โžค Now, go back to your spreadsheet, and youโ€™ll see the total count of each color displayed in column F, next to the matching color key in column E.

Using Apps Script to Count by Fill Color


2

Using the Function by Color Add-On

The Function by Color add-on is a simple way to count colored cells in Google Sheets. It lets you count or sum cells based on their background color.

Hereโ€™s how to use this tool in 2 steps:

Step 1: Install the Function by Color

โžค Open your Google sheets file where you have a dataset with highlighted cells.
โžค Go to the top Menu, and click Extensions >> Add-ons >> Get add-ons.

Using the Function by Color Add-On

โžค Search for Function by Color in the Google Workspace Marketplace.
โžค Click Install and approve the required permissions.

Using the Function by Color Add-On

โžค Once installed, the add-on will be listed under your Extensions menu.
โžค Click Done.

Using the Function by Color Add-On

Step 2: Use Function by Color Tool to Count Highlighted Cells

โžค Go back to your Spreadsheet.
โžค Next, go to the top Menu, and click Extensions >> Function by Color >> Start.

Using the Function by Color Add-On

โžค A sidebar will appear on the right side of your screen.
โžค In the Select range box, enter your colored cell range. For example, type C2:C11. โžค In the Select color box, use the color picker to select the specific color you want to count.
โžค From the Use Function dropdown menu, choose COUNTA (text).
โžค In the Paste result to field, enter the cell where you want to display the result. For example, type F2.
โžค Next, click the Insert Function button at the bottom of the sidebar.

Using the Function by Color Add-On

โžค Youโ€™ll now see the total number of cells with the selected background color appear in that cell.

Using the Function by Color Add-On

Note:
Repeat the process for each color in your reference list by updating the range, choosing a new color, and selecting a new result cell.


3

Using COUNTIF Function to Count Highlighted Cells by Text Value

In this version of the dataset, only the Color column has been updated to display text labels such as Not Started, In Progress, and Completed. It now shows the matching status values found in the main table. These labels represent each category of task status.

Weโ€™ll use this setup to apply the method for counting highlighted cells based on text values using a simple built-in formula in Google Sheets.

Using COUNTIF Function to Count Highlighted Cells by Text Value

COUNTIF function is a simple built-in method to count highlighted cells in Google sheets based on text. If the colored cells in your dataset also contain consistent text values like Completed, In Progress, or Not Started, you can use the built-in COUNTIF function to count them. This method focuses on the text content inside the cells rather than their background color.

Hereโ€™s is an easy guide how to apply this method:

โžค Open your dataset in the Google sheets.
โžค Select an empty cell where you display the result of counting highlighted cells. For example, select cell F2 next to the label Not Started.

Using COUNTIF Function to Count Highlighted Cells by Text Value

โžค Enter this formula =COUNTIF(Range, Cell_Text). For example, type the following formula

=COUNTIF(C2:C11, E2)

Using COUNTIF Function to Count Highlighted Cells by Text Value

โžค Click Enter. This will return the number of tasks marked as Not Started.

Using COUNTIF Function to Count Highlighted Cells by Text Value

โžค To apply the same formula to the other rows, drag the fill handle from F2 down to F4 and the values will update automatically.

Using COUNTIF Function to Count Highlighted Cells by Text Value


Frequently Asked Questions

How do I count the number of highlighted cells in Google Sheets?

You can count highlighted cells in Google Sheets using a custom Apps Script.ย  Hereโ€™s a simple steps to apply this method:

โžค Open your Google Sheet and go to the top Menu.
โžค Click on Extensions >> Apps Script.
โžค Delete any existing code and paste your script.
โžค Click the Save icon to save the script.
โžค Next, click the Run button to execute the script.
โžค Now, go back to your spreadsheet and youโ€™ll see the result.

How to select only highlighted cells in Google Sheets?

Thereโ€™s no direct way to select only highlighted cells, but hereโ€™s a simple workaround:

โžค Apply a filter to your dataset by clicking Data >> Create a filter.
โžค Click the filter icon on your column header.
โžค Choose Filter by color > Fill color, and select the highlighted color.

This will display only the rows with the highlighted cells, which you can copy or work with as needed.


Wrapping Up

These simple methods help you count highlighted or color-coded cells in Google Sheets. If you’re tracking colors visually, the Function by Color add-on makes it easy without any formulas.

And when you need more flexibility, a custom Apps Script lets you count by filling color directly. The COUNTIF function works best when your sheet uses consistent text values, as it counts based on the cell content rather than background color.

Each method offers a different level of control, depending on how your data is structured. By learning how to apply these techniques, you can keep your spreadsheets more easier to work with.

Facebook
X
LinkedIn
WhatsApp
Picture of Sazeda Rahman

Sazeda Rahman

Sazeda Rahman Setu holds a BSc and MSc in Mathematics from National University, providing a strong foundation in analytical and logical thinking for spreadsheet work. Since May 2025, she has gained hands-on experience with Excel and Google Sheets, focusing on formulas, functions, troubleshooting, and step-by-step tutorials. She enjoys creating example datasets and clear guides to help beginners solve spreadsheet problems.
We will be happy to hear your thoughts

Leave a reply


Excel Insider
Logo