How to Use “Not Equal to” Operator for Text in Excel (5 Examples)

To compare one text with another in Excel, use Logical Operators. If one text is not equal to another in Excel, use the “Not Equal to” operator.

Examples are shown below:


Excel If Not Equal to Text

Introduction to “Not Equal to” Operator in Excel

The Not Equal to operator is used for comparing two values. Its function is opposite to the Equal (=) operator. Excel takes a pair of angle brackets (<>) as the Not Equal to operator. It returns a Boolean expression either TRUE (when not equal to) or FALSE (when equal to).

Not Equal to Operator

Method 1 – Compare a Text with Another Using “Not Equal to” Operator Directly

To compare Text 1 and Text 2 from this dataset:

Sample Dataset


  • Enter the following formula for comparing cells B5 and C5.


Apply formula with Not Equal to operator

  • Press ENTER and the cell will return TRUE as the text values of these two cells don’t match.
  • Drag the Fill Handle tool downward to Autofill the formula below.

Autofill formula

  • The Boolean result will be shown after comparing all the text values.

Compare text in Excel If Not Equal to Text

Method 2 – Use of “Not Equal to” Operator in IF Function to Set a Logical Test


  • Apply the following formula to match cell B5 with C5.

=IF(B5<>C5,"Matched","Not Matched")

IF Function with Not Equal to operator in Excel

  • Press ENTER and copy the formula down to the other cells. If the text values match, Excel will return “Matched” else “Not Matched”.

Result of IF function

Method 3 – Apply “Not Equal to” Logic in SUMIF Function to Get Sum Excluding a Text Set Beforehand

To calculate the total price from this dataset excluding the item: Mobile.

SUMIF Function with Not Equal to operator in Excel


  • Enter the formula in cell C12.


  • C5:C9 = range
  • D5:D9 = sum range
  • “<>”&C11 = criteria (not equal to cell value of C11)

SUMIF Function

  • It will return the total price of the products excluding Mobile (i.e. 18000).

Output of SUMIF Function

Method 4 – Using “Not Equal to” with COUNTIF and COUNITFS Functions

4.1 Single “Not Equal to” Criterion (COUNTIF Function)


  • Select a cell and add the formula below.


  • C5:C11 = range
  • “<>”&C13 = criteria

COUNTIF Function with Not Equal to Operator for comparing Text in Excel

  • Press ENTER to count the number of items excluding Mobile.

COUNTIF function for Text

4.2 Multiple Simultaneous “Not Equal to” Criteria (COUNTIFS Function)

To count the items without “Mobile” and “TV”:


  • Apply the following formula in a selected cell.


  • C5:C11 = criteria range
  • “<>”&”Mobile” = criteria 1
  • “<>”&”TV” = criteria 2

COUNTIFS in Excel If Not Equal to Text

  • Press ENTER to count the total cells excluding Mobile and TV.


Method 5 – Use of “Not Equal to” Criteria with AVERAGEIF Function to Get Average Except for an Item

To find the average sales of Male and Female Sales reps respectively from the given dataset:

Dataset for AVERAGEIF


  • Apply the following formula to get the average sales by the Male sales reps.


  • C5:C11 = range
  • “<>”&”Male” = criteria
  • D5:D11 = average range

AVERAGEIF in Excel If Not Equal to Text

This formula will take the Male from the range C5:C11 and calculate the corresponding sales values from the range D5:D11 and calculate the average of the Male reps.

  • To calculate the average of Female sales reps, apply the formula below.



Things to Remember

  • The “Not Equal to” operator is not case-sensitive. So, if you have the same words with uppercase and lowercase (i.e. Rat and rat), it will return FALSE.
  • You need at least two variables to apply this operator.

Download Practice Workbook

<< Go Back to Text | If Cell Contains | Formula List | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Rafiul Hasan
Rafiul Hasan

Rafiul Hasan, holding a BSc in Naval Architecture and Marine Engineering from Bangladesh University of Engineering & Technology, contributes significantly to the ExcelDemy project with almost 1.6 years of dedicated work. Currently an Excel and VBA Content Developer, he has a passion for problem-solving. Authoring over 100 articles for ExcelDemy showcases expertise in Microsoft Office Suites and Data Analysis. In addition to content development, Rafiul actively engages with the ExcelDemy forum, offering valuable solutions to user queries and... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF