IF Statement comparing text

Les M 80 Reputation points
2026-01-20T11:57:14.6866667+00:00

When comparing string value in an IF statement, does it matter if the string is all uppercase or not?

EXAMPLE: IF lastname = "Doe" OR lastname = "DOE" Then.....

I am just wondering if it matters or do I actually need to check both like the above code is doing.

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2026-01-20T11:57:21.4866667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    When comparing string values in an IF statement, it does matter whether the strings are in uppercase or lowercase unless you specify a case-insensitive comparison. In many programming languages, string comparisons are case-sensitive by default, meaning that "Doe" and "DOE" would be considered different strings.

    To avoid having to check both variations, you can use a case-insensitive comparison method. For example, in Visual Basic, you can use the Option Compare statement to set the comparison mode to case-insensitive, or you can explicitly use a method that allows for case-insensitive comparison. This way, you can write your IF statement without needing to check both cases separately.

    In summary, if you want to treat "Doe" and "DOE" as equal, you should use a case-insensitive comparison method instead of checking both conditions separately.


  2. riny 20,765 Reputation points Volunteer Moderator
    2026-01-20T16:27:33.6233333+00:00

    Not sure why you accepted a nonsense AI answer. IF in Excel is NOT case sensitive. Try it and you'll see for yourself. Though, there are functions that are case sensitive in Excel. For instance, FIND is but SEARCH is not. Please un-accept the AI answer and delete it.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.