VBA - 一次多字符串比较

时间:2017-11-27 14:28:55

标签: excel vba excel-vba

我有一段愚蠢的代码来测试变量是否是某个字符串:

If Target.Cell.Value = "1M" or Target.Cell.Value = "1N" or Target.Cell.Value = "1O" Then
...
End If

有没有办法压缩if语句 - 即与列表或类似的东西进行比较?

谢谢 - KC

1 个答案:

答案 0 :(得分:3)

Select Case Target.Cell.Value
Case "1M","1N","10" 
     ...
end select