在比较stringvba时input不匹配错误13

这个语法有什么问题吗?

If xlwsIAR.Cells(x, 5).Text <> "FTD-OPEN" Or "FTD-CLOSE" Then ''action ''action ''action End if 

因为我试图检查一个单元格,如果它具有特定的标准。

VB / VBA是比较条件下具体的。 尽pipe可以将其与常量数组进行比较,但是您的语法可能更好地逐块构build。

 If UCase(xlwsIAR.Cells(x, 5).Text) <> "FTD-OPEN" And UCase(xlwsIAR.Cells(x, 5).Text) <> "FTD-CLOSE" Then 

由于string常量是大写字母,VBAstring比较默认情况下是大小写敏感的,所以我引入了一些UCase函数 。