Function Problems

How to Count Rows Where One Column Contains Text and Another Does Not in Excel

Tauseeq MagsiTauseeq Magsi Nov 10, 2026 869 views

Question details

The user needs to count specific rows based on multiple text criteria across two columns, specifically including one text value while excluding another.

How to Count Rows Where One Column Contains Specific Text and Another Does Not
Product
Excel
Device & OS
not provided
Scenario
Filtering data records to count the exact number of occurrences that meet both an inclusion and an exclusion text criteria.
Observed behavior
A formula is needed to output the total count of rows matching the specified text inclusion in Column A and text exclusion in Column B.
Before you start

Ensure your data ranges are consistent in size and do not contain hidden rows or trailing spaces that might interfere with text recognition in your formulas.

Solution 1Recommended

Use COUNTIFS with Wildcards for Partial Text Matches

Best for when you need to find rows where a column contains a specific word within other text, while another column does not contain a specific word.

The COUNTIFS function allows you to apply multiple criteria to different ranges. By combining it with asterisk wildcards (*), you can search for substrings of text anywhere within a cell.

1
Select a destination cell

Click on the empty cell where you want the final count result to appear.

2
Enter the formula

Type the formula =COUNTIFS(A:A,"*TEXT 1*",B:B,"<>*ANSWER 1*"). Replace 'TEXT 1' with the word you want to include, and 'ANSWER 1' with the word you want to exclude.

3
Calculate the result

Press Enter to execute the formula and view the total number of matching rows.

Use COUNTIFS with Wildcards for Partial Text Matches
Wildcard Usage: The asterisks (*) act as wildcards, meaning the specified text can appear at the beginning, middle, or end of the cell's contents. The <> operator means 'does not equal'.
Advanced Spreadsheets

Count Complex Data Sets Easily with WPS Spreadsheet

WPS Spreadsheet offers full support for advanced Excel functions like COUNTIFS, allowing you to filter, analyze, and manage complex datasets with ease.

  1. 1. Open your data file: Launch WPS Spreadsheet and open the document containing your data set.
  2. 2. Select output cell: Click on the cell where you wish to display the counted result.
  3. 3. Type the formula: Enter your =COUNTIFS formula using the specific inclusion and exclusion criteria.
  4. 4. Execute: Hit Enter to instantly view your calculated row count.
100% compatible with Microsoft Excel formulas and wildcardsUser-friendly interface for faster data analysisBuilt-in formula error-checking toolsLightweight and runs smoothly on all devices
microsoft office alternative - wps office

Frequently Asked Questions

Why is my COUNTIFS formula returning 0 even though there are matching rows?

This usually happens if there are invisible trailing spaces in your cells or if the text criteria are misspelled. Try using the TRIM function on your data ranges to remove extra spaces, or verify the spelling of your criteria.

Can I apply this formula to more than two columns?

Yes, the COUNTIFS function can handle up to 127 range/criteria pairs. Just append the next range and criteria separated by commas, such as =COUNTIFS(A:A,"*Text*", B:B,"<>*Text2*", C:C,"Criteria3").

Are COUNTIFS text criteria case-sensitive?

No, the COUNTIFS function in both Microsoft Excel and WPS Spreadsheet is not case-sensitive. Words like "TEXT", "Text", and "text" will be treated as the exact same value.

How do I exclude blank cells from the row count?

To exclude blank cells from your final count, add an additional criteria pair to your COUNTIFS formula: A:A, "<>" which ensures the cell being evaluated is not completely empty.