vba case sensitive compare code example
Example 1: vba ignore case
Option Compare Text
Option Compare Binary
Debug.Print StrComp(string1, string2, vbUseCompareOption)
Debug.Print StrComp(string1, string2, vbBinaryCompare)
Debug.Print StrComp(string1, string2, vbTextCompare)
Example 2: excel vba Case-Insensitive String Comparison
MsgBox LCase(str1) = LCase(str2)
MsgBox 0 = StrComp(str1, str2, vbTextCompare)
StrComp() will return -1 if str1 is less than str2.
StrComp() will return 0 if str1 is equal to str2.
StrComp() will return 1 if str1 is greater than str2.