A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Hi Les M
Here is another formula option/solution =IF(LOWER(C2)="doe","Yes","No")
I hope this helps you
Thanks
Kind regards
Jeovany CV
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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.
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Hi Les M
Here is another formula option/solution =IF(LOWER(C2)="doe","Yes","No")
I hope this helps you
Thanks
Kind regards
Jeovany CV
Oops. Sorry. Looks like you wanted vba.
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.
AI answer
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.