我有一个Excel VBA公式: -
If [G56] = "Not Applicable" Then
...
区分大小写。我希望它忽略"不适用"
的情况答案 0 :(得分:3)
您可以使用LCase功能:
If LCase([G56]) = "not applicable" Then
答案 1 :(得分:3)
您还可以使用专用函数来比较字符串:
p1
中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
方法的更多信息
答案 2 :(得分:1)
或在模块顶部添加Option Compare Text
:
Option Explicit
Option Compare Text
Sub Test()
MsgBox "Not Applicable" = "Not applicable" 'True
End Sub
答案 3 :(得分:0)
最快的选择是
StrComp(LCase$("Not Applicable"), "not applicable", vbBinaryCompare)