Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 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

by Allen Wyatt
(last updated May 29, 2021)


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 Office 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. ...


Triggering an Event when a Worksheet is Deactivated

One way you can use macros in a workbook is to have them automatically triggered when certain events take place. Here's ...

Discover More

Comments in Headers and Footers

Comments can be a necessity when developing documents in conjunction with other people. They can be used to help document ...

Discover More

Excel Charts in PowerPoint

A common place to use Excel charts is in your PowerPoint presentations. How you paste those charts into the presentation ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Replacing Dashes with Periods

Replacing one character in a text value with another character is easy. All you need to do is use the SUBSTITUTE ...

Discover More

Finding Circular References

If you have circular references in a workbook, you may see an error message appear when you first open that workbook. If ...

Discover More

Transposing and Linking

Sometimes it is helpful to look at data that is rotated 90 degrees. Excel allows you to use Paste Special to transpose ...

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}] 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 9 + 8?

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.