Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Ignoring Case in a Comparison.

Ignoring Case in a Comparison

Written by Allen Wyatt (last updated May 29, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


If you use Excel's IF function to compare two cells that contain text, Excel, by default, ignores the case of the text being compared. For instance, if cell B3 contains "Case" and cell B4 contains "case", then the following formula returns "Match".

=IF(B3=B4,"Match","No Match")

There is no way to modify this behavior using any settings in Excel. If you do not get these results, it is likely because of some other reason. For example, the text in the cells may look the same, but it may not really be the same. For instance, one cell could contain "Case " (with the trailing space), and the other contain "case". In this instance, the formula would return "No Match", and you would assume it is because of the capitalized C in one of the cells, but the real reason is because of the trailing space. You can confirm this by changing the formula, as follows:

=IF(TRIM(B3)=TRIM(B4),"Match","No Match")

The only difference here, of course, is that the TRIM function is used to return a cell value that has all leading and trailing spaces removed.

If you want Excel to actually take text case into account, you should use the EXACT statement, as shown here:

=IF(EXACT(B3,B4),"Match","No Match")

The EXACT function returns True if the cells are exactly the same, otherwise it returns False.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11118) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Ignoring Case in a Comparison.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Differences between Deleting, Clearing, and Cutting

When getting rid of text from your document, Word allows you to delete, clear, or cut. Here are the differences between ...

Discover More

Displaying the Document Title Right Away

One of the properties that Word maintains for a document is a title. If you want this title displayed on the title bar ...

Discover More

Inserting a Watermark Behind Merged Cells

If you have a group of merged cells into which you want a user to enter information, you may want some sort of ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Combinations for Members in Meetings

Got a large group of people listed in a worksheet and you want to make sure that each person has met with every other ...

Discover More

Tracing Errors

Sometimes it can be confusing to figure out the source of an error that is displayed in your worksheet. Excel provides a ...

Discover More

Splitting Cells by Case

Excel provides several different ways that you can split apart the contents of a cell. One way it doesn't provide is to ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one more than 9?

2021-06-09 05:02:45

Alan Elston

John ,
Your question is a bit off topic / out of place here, -
... - you might find some info on that date stuff here: …
…. …..
…. ….
….. …..

…. Alan Elston

2021-06-08 20:18:48

John Rogers

Hi Allen,
Thankyou for sending me your wonderful EscelTips - they are so very helpful.
I am writing to request for help with a problem I've been having for a while: that of selecting the default format for the date. In Open Office Calc (which mimics Excel) the date defaults to the US format. I prefer the Australian format - dd/mm/yy and whereas I know how to select this for individual cells - I would like to know how to do it as a default setting.

John Rogers

2021-05-31 02:09:43

Alan Elston

Hi Willy, Hi J Woolley
I feel your pain, J. Woolley! …. But I think it’s a general characteristic of almost all Blog site, Forum and most Message Editor windows - this annoying “eating of spaces more than one space”.
No one’s been able to explain to me why it’s done. I can’t see that with modern computers that any saving of memory space can justify the annoyance it often causes. Possibly what Willy said in his first comment explains what’s going on. I must think about tha, I don't really understand so much about HTML stuff.
( I will be taking ownership of one of the Excel Forums at the end of this year, and one thing I hope to do is remove this annoying characteristic, if its possible.
_.... but maybe I don’t need to ….. )
That sounds like a very interesting thing to experiment with , Willy.
That is something completely new that I never tried before.. Thanks for that great tip

I must go and investigate that in a few places.

If I have anything useful to add I will post back here…. I expect it is one of those annoying things like carriage returns where you get different and seemingly inconsistent results in different systems. It probably needs some thorough investigations to track down and control consistently…

Alan Elston

2021-05-30 10:36:15

J. Woolley

Sometimes that works for me if I prepare the comment in Notepad using Alt+0160 for non-breaking (hard) spaces, then copy and paste the comment for posting on this site. I'll try it here with my previous examples:
Excel's TRIM("    Now    is    the    time    ") yields "Now is the time"
VBA's Trim("    Now    is    the    time    ") yields "Now    is    the    time"

2021-05-30 05:31:39

Willy Vanhaelen

@J. Woolley
Oops ! doesn't work any more :-)

2021-05-30 05:29:42

Willy Vanhaelen

@J. Woolley
HTML renders only one space even if there are many. You can avoid this by using hard spaces. Hold down the left Alt and type 0160 (or 255) on the numeric key pad. For instance " " are 4 hard spaces.

2021-05-29 10:29:23

J. Woolley

Posting comments on this site is frustrating. I guess Allen uses the TRIM function because he removed "all spaces from text except for single spaces between words" in my previous comment (below). Please ignore those examples.

2021-05-29 10:23:46

J. Woolley

Re. Excel's TRIM function described above, it actually "Removes all spaces from text except for single spaces between words."
TRIM(" Now is the time ") yields "Now is the time"

However, VBA's Trim function returns a "value that has all leading and trailing spaces removed."
Trim(" Now is the time ") yields "Now is the time"

This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.