IRONSOFTWAREHOME
엑셀 도구

How to Count Cells with Text in Excel: A Step-by-Step Guide (.NET 10, C#)

Curtis Chau
Curtis Chau
Updated: 2026년 8월 16일

Counting cells with text in Excel sounds like a simple task, but it can quickly become tricky depending on your data set. Whether you need to count cells that contain specific text, filter out empty cells, or tally text values while skipping numeric values, Excel offers multiple ways to handle text matching.

In this guide, we will cover everything from basic COUNTIF formulas to advanced array formulas and developer-focused automation tools.

Method 1: The COUNTIF Function (The Standard Way)

The standard way to count cells with text in Excel is using the COUNTIF function. The COUNTIF function counts the number of cells within a range that meet specific criteria.

Formula Structure

To count all cells containing any text string in a range, use the following formula with a wildcard character:

=COUNTIF(A2:A11, "*")
Text

The asterisk (*) acts as a wildcard character representing any sequence of characters.

Step-by-Step

  1. Select the cell where you want the total count to appear.

  2. Enter =COUNTIF(A2:A11, "*") into the formula bar, replacing A2:A11 with your target range.

    Enter the function

  3. Hit enter to get your result.

    COUNTIF function output

참고해 주세요: The COUNTIF function is case insensitive by default, meaning "APPLE", "Apple", and "apple" will match as the exact same text values.

Method 2: Counting Cells with Specific Text or Partial Match

When analyzing spreadsheet data, you often need to count cells that contain a specific word, phrase, or sub-string.

Counting Specific Text (Exact Match)

To count cells that contain an exact text string, enclose the phrase in double quotation marks:

=COUNTIF(A1:A10, "apple")
Text

This COUNTIF formula checks the cell reference range and counts every instance where the text equals "apple".

COUNTIF Exact match output

Partial Match with Wildcards

If you need a partial match, for instance, counting cells that contain "apple" anywhere inside a longer text string, wrap the term in asterisks:

=COUNTIF(A1:A10, "*apple*")
Text

COUNTIF partial match output

  • Starts with specific text: =COUNTIF(A1:A10, "apple*")
  • Ends with specific text: =COUNTIF(A1:A10, "*apple")
  • Single character wildcard: Use the question mark (?) to match any single character. For example, =COUNTIF(A1:A10, "a?ple") matches "apple" or "ample".

Method 3: Counting Text Values While Excluding Empty Cells and Numbers

A common issue in Excel is distinguishing between text values, numeric values, true and false values, and blank cells.

How to Count Non-Empty Cells

If your goal is simply to count non-empty cells regardless of data type, use the COUNTA function:

=COUNTA(A1:A10)
Text

Counting all non-empty cells However, COUNTA counts all cells with data, including numeric values, errors, and boolean true and false values.

Counting ONLY Text Cells (Excluding Numbers & Blanks)

To count cells with text in Excel while ignoring numeric values, formulas that return numbers, and empty cells, combine SUMPRODUCT and ISTEXT:

=SUMPRODUCT(--ISTEXT(A1:A10))
Text

Counting only text cells

팁: The double unary operator -- converts TRUE and FALSE logical outputs from ISTEXT into 1s and 0s, allowing SUMPRODUCT to sum the total number of text entries accurately.

Because COUNTIF is case insensitive, searching for upper and lower case distinctions requires a different approach using the EXACT function and SUMPRODUCT function.

=SUMPRODUCT(--EXACT("Apple", A1:A10))
Text

Case sensitive text search This formula compares the search string "Apple" against each cell in the range. It returns TRUE only when the case matches exactly, converting false values to 0 and true values to 1.

How to Count the Number of Cells with Unique Text in Excel

To count the number of cells that contain unique text strings while ignoring duplicate entries and blank cells, use this array formula:

=SUMPRODUCT((A1:A10<>"")/COUNTIF(A1:A10, A1:A10&""))
Text

Counting the number of unique cells

How this formula counts:

  1. A1:A10<>"" filters out empty cells and blank strings.
  2. COUNTIF(A1:A10, A1:A10&"") evaluates how many times each item appears in the range.
  3. SUMPRODUCT sums the reciprocal values, yielding the exact count of unique text entries.

Quick Comparison of Text Counting Methods

Goal / CriteriaFormula ExampleHandles Wildcards?Case Sensitive?
All text cells=COUNTIF(A1:A10, "*")YesNo
Specific text match=COUNTIF(A1:A10, "apple")YesNo
Partial match=COUNTIF(A1:A10, "*apple*")YesNo
Only text (ignore numbers)=SUMPRODUCT(--ISTEXT(A1:A10))NoN/A
Exact case match=SUMPRODUCT(--EXACT("Apple", A1:A10))NoYes

Troubleshooting Common Errors

  • Cells with invisible spaces: Cells containing hidden space characters or empty strings ("") from formulas may be counted as text by COUNTIF. Fix this by cleaning your data range using TRIM() or CLEAN().
  • Incorrect cell reference: Double-check your named range or absolute cell references ($A$1:$A$10) when copying formulas across a row or column to prevent shifting criteria.
  • Unexpected numeric skips: Remember that standard wildcards like "*" ignore numeric values completely. If your text string is actually stored as a number, use SUMPRODUCT instead.

Automating Spreadsheet Operations with IronXL

For developers building enterprise applications, handling spreadsheet calculations manually isn't an option. IronXL is a robust .NET library designed to manage Excel files programmatically in C#, VB.NET, and F# without requiring Microsoft Excel installation.

Whether you need to count cells based on specific criteria, extract text from massive data sets, or validate user inputs in a spreadsheet, IronXL simplifies document processing in just a few lines of code.

Counting Text Cells Programmatically in C#

Using IronXL to load an existing worksheet, iterate through a target range, and count cells that contain text:

using System;
using IronXL;

// Load an existing Excel workbook
WorkBook workbook = WorkBook.Load("DataReport.xlsx");
WorkSheet worksheet = workbook.DefaultWorkSheet;

int textCellCount = 0;

// Iterate through a designated range of cells
foreach (var cell in worksheet["A1:A100"])
{
    // Check if the cell value contains text and is not blank
    if (cell.IsText && !string.IsNullOrEmpty(cell.StringValue))
    {
        textCellCount++;
    }
}

Console.WriteLine($"Total number of cells with text: {textCellCount}");
Text

IronXL Output

IronXL output

Summary

Knowing how to count cells with text in Excel efficiently saves hours of manual data checking. For quick interactive analysis, use the COUNTIF function with wildcards like * and ?. When working with complex criteria, case sensitivity, or filtering out numbers, use SUMPRODUCT alongside ISTEXT or EXACT.

If your business needs to scale spreadsheet workflows, perform automated reporting, or process data server-side, check out IronXL to handle Excel automation in code. Ready to try it in your own projects? Start your fully functional 30-day free trial of IronXL to experience fast, code-driven spreadsheet manipulation.

Curtis Chau
기술 문서 작성자

커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.

...
더 읽어보기

관련 기사

Key in blue circle

무료 30일 체험 키를 즉시 받으세요.

Your trial license will be sent to your email address

제한 없음. 100% 무제한 이용. 신용카드 불필요.

bullet_checked신용카드나 계정 생성은 필요하지 않습니다.제한 없음. 100% 무제한 이용. 신용카드 불필요.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
무료 라이브 데모를 예약하세요
Booking Badge

전 세계 수백만 엔지니어들이 신뢰하는 제품입니다.

Iron Software의 고객 로고
부담 없는 무료 상담을 받아보세요
아래 양식을 작성하시거나 sales@ironsoftware.com으로 이메일을 보내주세요.
고객님의 정보는 항상 비밀로 유지됩니다.
전 세계 수백만 엔지니어들이 신뢰하는 제품입니다.
Iron Software의 고객 로고
지금 바로 30일 무료 체험판 키를 받으세요.
신용카드나 계정 생성은 필요하지 않습니다.