CountIf Formula with Blank Cells: Include or Exclude?

Abstract: Use COUNTIF with an empty string to count blank cells or an asterisk wildcard to exclude them from Excel totals.

Created: 2026-08-27 by
The COUNTIF function in Excel excludes blank cells by default because it only counts cells that contain data. To include blanks, you must use the asterisk wildcard character as the criteria argument. This simple adjustment ensures that empty cells are treated as valid entries for your count.

Understanding Default Behavior

When you use the standard COUNTIF function, Excel evaluates the range of cells against a specific condition. By default, if you do not provide any criteria or if the criteria is an empty string represented incorrectly, the function ignores cells that appear empty. This behavior is designed to prevent statistical errors in datasets where missing data should not be counted as zero or null values unless explicitly intended.

For example, if you have a list of sales figures and some cells are genuinely empty because no sale occurred, using =COUNTIF(A1:A10,"") might seem like the right approach to count those empty spots. However, users often find that this returns zero when they expect it to return the number of blank cells. This confusion arises because the syntax requires precise handling of the criteria argument to target blankness specifically.

How to Include Blank Cells

To explicitly count blank cells, you need to pass an empty string as the criteria. The correct formula structure is =COUNTIF(range, ""). This tells Excel to look for cells that are either truly empty or contain only spaces, depending on how the data was entered. If you want to count cells that are strictly empty (not even containing spaces), this method works perfectly for most standard datasets.

Consider a scenario where column A contains customer names, and some rows are incomplete. You can determine how many customers are missing their names by applying the following formula in an empty cell:

=COUNTIF(A2:A100, "")

This formula scans from A2 to A100 and increments the counter for every cell that appears blank. It is crucial to ensure that the quotes are standard double quotes and that there is nothing between them. Any deviation, such as adding a space inside the quotes like " ", will change the result to count only cells with single spaces, which is a different condition entirely.

Excluding Blank Cells from Counts

Sometimes, the goal is to count non-blank cells, effectively excluding blanks from the total. While COUNT and COUNTA functions handle numbers and text respectively, COUNTIF offers more flexibility when combined with other conditions. To exclude blanks while counting specific values, you can use a wildcard. For instance, to count all cells that are not blank, you can use =COUNTIF(range, "*").

The asterisk wildcard matches any sequence of characters. When used as the criteria, it forces Excel to ignore cells that are completely empty. This is particularly useful when you have a mixed dataset containing both numbers and text, and you want to know the total volume of recorded entries regardless of their content type. This approach is robust because it treats any visible character as a valid entry.

If you are working with complex reports that involve color-coded summaries, understanding these exclusion principles helps maintain accuracy. For deeper insights into managing conditional formatting alongside counts, you might find value in exploring CountIFs Beyond: Summarizing Red and Yellow Cells in Excel. This resource details how to integrate visual cues with logical formulas for comprehensive data analysis.

Handling Spaces vs. True Blanks

A common pitfall involves cells that look blank but actually contain a space character. These cells are not technically empty; they contain a single character with a width of one unit. The formula =COUNTIF(range, "") will not count these cells because they are not empty. Conversely, =COUNTIF(range, " ") will count only those specific space-filled cells.

To address this, you may need to clean your data first. Using the TRIM function can remove leading and trailing spaces, converting space-only cells into true blanks. Once cleaned, the original COUNTIF logic applies correctly. Always verify your data integrity before relying on count results, especially when importing data from external sources where invisible characters are common.

Related Counting Functions

Beyond COUNTIF, Excel provides other functions that handle blanks differently. The COUNT function only counts cells containing numbers, automatically ignoring text and blanks. The COUNTA function counts all non-empty cells, including text, numbers, and error values, but still ignores true blanks. Understanding the distinction between these functions helps you choose the right tool for your specific reporting needs.

For example, if you are tracking duplicate entries in a list, knowing whether to include blanks affects your duplicate detection logic. You can refer to Troubleshooting Excel Duplicate Values to see how blank handling impacts duplicate identification algorithms. This ensures that your deduplication processes do not mistakenly flag empty rows as duplicates or miss actual duplicates due to inconsistent blank handling.

Frequently Asked Questions

Why does my COUNTIF return zero for blank cells?

Your formula likely lacks the empty string criteria or contains unintended spaces. Ensure you are using "" exactly as shown. If the cells contain spaces, use " " instead. Verify that the range selected matches the data you intend to analyze.

Can I count blanks and non-blanks in the same formula?

You cannot do this directly in a single COUNTIF call. However, you can sum two separate COUNTIF results. For example, add =COUNTIF(range, "") and =COUNTIF(range, "<>") together. This gives you the total number of cells in the range, confirming your count covers all possibilities.

Does COUNTIF count cells with formulas returning empty strings?

No, it depends on the context. If a formula returns "", Excel treats it as a blank for COUNTIF purposes. However, if the formula returns a space " ", it is not considered blank. Check the underlying formula output to determine if it produces a true empty state or a visible character.

How do I count blanks in a filtered table?

Standard COUNTIF counts all cells in the range, including hidden ones. To count only visible blanks after filtering, use SUBTOTAL(103, range) combined with other logic, or use COUNTIFS with visibility checks if available. Alternatively, filter the data first and then apply the count to the visible selection manually.

What is the difference between COUNTBLANK and COUNTIF for blanks?

COUNTBLANK is a dedicated function that counts only empty cells. COUNTIF(range, "") achieves the same result but allows for more complex criteria combinations. Use COUNTBLANK for simplicity, but prefer COUNTIF when you need to add additional conditions, such as counting blanks in specific columns based on row headers.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More