- How to count cells in Google Sheets
- How to count cells in Google Sheets by color
- How to count text cells in Google Sheets
- How to count selected cells in Google Sheets
- How to count filtered cells in Google Sheets
- How to Count Bold Cells in Google Sheets
- How to count blank cells in Google Sheets
- How to count non-blank cells in Google Sheets
- Count cells like a pro
When you’re compiling a spreadsheet in Google Sheets, you may need to know the number of certain cells. Different Google Sheets functions and formulas are usually used to count blank and non-blank cells. This task may seem complicated to new Google Sheets users, but once you master it, you’ll see that counting cells in this online program is just a matter of designated steps.
In this article, we’ll show you how to count various types of cells in Google Sheets, including text cells, selected cells, filtered cells, and more.
How to count cells in Google Sheets
If your Google Sheets document only has a few columns and rows, you can always count the number of cells manually. However, if the spreadsheet contains a large database, knowing how to use formulas to count cells in Google Sheets can save you a lot of time.
To count cells in Google Sheets, we will use some special formulas. Specifically, COUNT functions are used to count the number of cells that fall within a specific data range. The two most common and useful types of COUNT functions in Google Sheets are COUNT and COUNT.
The COUNTA formula indicates the number of numerical values within a data set. The COUNTIF formula is used to determine a conditional count in a range. It is written like this: COUNTIF (range, criterion), where the range is compared to the criterion. Sometimes you can use the SUMPRODUCT formula, which shows the sum of products of corresponding ranges in two arrays.
How to count cells in Google Sheets by color
There is no direct way to count the number of cells based on the background color. Instead, you’ll have to use a custom function with Google Apps Script.
First, you will need to copy this code.
“function countCellColored(countRange,colorRef) {
var activeRg = SpreadsheetApp.getActiveRange();
var activeSht = SpreadsheetApp.getActiveSheet();
var activeFormula = activeRg.getFormula();
var countRangeAddress = activeformula.match(/\((.*)\,/).pop().trim();
var backGrounds = activeSht.getRange(countRangeAddress).getBackgrounds();
var colorRefAddress = activeformula.match(/\,(.*)\)/).pop().trim();
var Background = activeSht.getRange(colorRefAddress).getBackground();
var cellcount = 0;
for (var i = 0; i
for (var k = 0; k
yes (funds[i][k] == Background)
countCells = countCells + 1;
return cellcount;
};”
This is how you can use this code to count cells in Google Sheets by color.
- Open Google Sheets.

- Find the spreadsheet you want to edit.

- Navigate to “Extension” in the menu and then to “Apps Script.”

- Delete the code in the Google Apps Script window.

- Paste the code provided above.

- Save your changes by clicking the disk icon at the top of the page.

- Close the Google Apps Script window.

- Enter “=COUNTCOLOREDCELLS” in any empty cell on the spreadsheet.

- Type the range in parentheses, as in this example: “=COUNTCOLOREDCELLS (A12:D15)”.

- Press “Enter” on your keyboard.
The number of colored cells will appear in the cell where you entered the formula.
How to count text cells in Google Sheets
In most cases, you will be prompted to count cells with text. It doesn’t matter what type of text the cells contain; They could be numbers, dates, names, etc. Note that there is a difference between counting cells with specific and non-specific text. We will use the COUNTIF formula for both.
To count non-specific text cells in Google Sheets, here’s what you need to do.
- Open Google Sheets.

- Locate the spreadsheet you want to use.

- Double click on an empty cell where the COUNT results will be.

- Type the formula “=COUNTIF” in the selected empty cell, or simply select it from the list of suggestions.

- Select the text cells you want to count by dragging the mouse over the range. Be
is automatically added to the COUNTIF formula. For example: “=COUNTIF(B4:C7” is what you are supposed to write for now (there are no closing parentheses yet).
Note: Another way to do this is to manually type the range after the opening parenthesis. For example, “(A7:C11”.
- Put the rating criteria in quotation marks (for example, “>20”). This is the only time we will use quotes in the formula. The criteria you use depends on the content of the cells.

- Add the closing parenthesis.

- Press the “Enter” key.
The number of text cells will appear in the cell where you entered the formula
How to count selected cells in Google Sheets
To count the number of selected cells in Google Sheets, you can use the COUNTA formula. This is how you do it.
- Gonna Google Sheets in your browser.

- Find the spreadsheet you want to use.

- Double-click any empty cell in the spreadsheet.

- Type “=COUNT” in the cell.

- Select the cells you want to count by clicking on the range and dragging the cursor over it. You can also enter the range in parentheses, as in the following example: “=COUNT(A1:B10)”.

- Press “Enter” on your keyboard.

You will see the number of selected cells in the same cell where you wrote the formula. We will not use quotes in the COUNT formula.
How to count filtered cells in Google Sheets
If you want to count cells with specific words, you can use the COUNTIF formula. For example, if you want to count all cells that contain the word “product”, the COUNTIF formula is ideal for this. Follow the steps below to see how it works.
- Run Google Sheets and locate your spreadsheet.

- Double-click anywhere on the spreadsheet.

- Type “=COUNTIF”.

- In parentheses, add the range. For example: “(A3:B10)”.

- Add a comma.

- Enter the filter word in quotes. This is what the formula “=COUNTIF(A3:B10, “product”)” is supposed to look like.

- Press “Enter.”
How to Count Bold Cells in Google Sheets
As with colored cells, there is no function you can use to count the number of bold cells in Google Sheets. You will need to use a custom formula with Google Apps Script. This is how you do it.
- Open Google Sheets and go to your spreadsheet.

- Navigate to “Extension” in the top menu.

- Select “Apps Script” from the list of options. This will take you to Google Apps Script.

- Remove the code that is already there.

- Copy and paste the following formula into the Code.gs window.
“function count cells in bold() {
var book = SpreadsheetApp.getActiveSpreadsheet();
var sheet = book.getActiveSheet();
var range_input = sheet.getRange(“E2:S7”);
var range_output = sheet.getRange(“G14”);
var cell_styles = range_input.getFontWeights();
variable count = 0; for(var r = 0; r for(var c = 0; c if(cell_styles[r][c] === “bold”) {
count = count + 1;
}
}
}
range_output.setValue(count)
}”
- Select the “Save” icon above the code.

- Close the Google Apps script.
Now that you’ve added the ability to count bold cells in Google Sheets, here’s what you need to do next.
- Type “=COUNTBOLDCELLS” in an empty cell.

- Enter the range, for example: “(A1:B10)”.

- Press the “Enter” key.
All cells in bold will be counted and the results will be displayed in that cell.
How to count blank cells in Google Sheets
Google Sheets allows you to count cells that do not contain text. These are called blank cells. We will count them using the COUNT BLANK formula. This is how you do it.
- Launch Google Sheets and open your spreadsheet.

- Choose any empty cell in the spreadsheet and double-click it.

- Enter “=COUNT BLANK” in the empty cell.

- Type the range of cells in parentheses, as in the example: “=COUNT BLANK (A:D)”.

- Press “Enter.”

That’s all about it. The number of blank cells will appear in that cell.
Note that Google Sheets differentiates between blank and empty cells. If there is an empty text string in a cell, Google Sheets sees it as an empty cell, not blank.
How to count non-blank cells in Google Sheets
To count non-blank cells in Google Sheets, we will use the COUNT function. This function is used to count cells that contain a text string or some type of value within a range. If there are blank cells between text cells, the COUNT function will not select them.
Follow the steps below to count non-blank cells in Google Sheets.
- Open Google Sheets and go to your spreadsheet.

- Choose an empty cell anywhere on the spreadsheet.

- Enter “=COUNT” in the empty cell.

- Type the range of cells in parentheses, for example: “(B5:B20)”.

- Press “Enter” on your keyboard.

The number of non-blank cells within a range will appear in the cell. If your spreadsheet has hidden or special characters, the COUNT function cannot help you. In these cases, it is better to use the COUNTIF or SUMPRODUCT function.
Count cells like a pro
Using Google Sheets can be complicated at first, especially if you’ve never used its formulas before. If you need to count specific cells in your spreadsheet, there is probably a formula that can help you. Otherwise, you’ll have to use a custom formula with Google Apps Script.