she*_*ngh 4 excel vba excel-2013
我有一个 Excel VBA 公式:-
If [G56] = "Not Applicable" Then
...
Run Code Online (Sandbox Code Playgroud)
它区分大小写。我希望它忽略“不适用”的情况。
您可以只使用 LCase 函数:
If LCase([G56]) = "not applicable" Then
Run Code Online (Sandbox Code Playgroud)
您还可以使用专用函数来比较字符串:
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
Run Code Online (Sandbox Code Playgroud)
这篇 MSDN 文章中有关于该StrCompare方法的更多信息