Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore case in string comparison

I have an Excel VBA formula:-

If [G56] = "Not Applicable" Then
    ...

It is case-sensitive. I want it to ignore the case of "Not applicable".

like image 398
sheetal singh Avatar asked Dec 19 '22 09:12

sheetal singh


2 Answers

You can just use the LCase function:

If LCase([G56]) = "not applicable" Then
like image 80
jvmeer Avatar answered Dec 29 '22 11:12

jvmeer


You can also use the dedicated function for comparing strings:

Dim result As Integer

'// vbTextCompare does a case-insensitive comparison
result = StrComp("Not Applicable", "NOT APPLICABLE", vbTextCompare)

If result = 0 Then
    '// text matches
End If

There is some more information on the StrCompare method in this MSDN article

like image 36
SierraOscar Avatar answered Dec 29 '22 11:12

SierraOscar