Sub CompareVariables() Dim a As String Dim b As String a = '所有类型' If a = '所有类型' Then b = a MsgBox 'a与b变量相同' Else a = Range('A2').Value MsgBox 'a的值为:' & a End If End Sub

VBA 字符串比较:判断变量是否为特定值