Excel-VBA统一两个逻辑语句

时间:2015-07-24 15:49:10

标签: excel vba excel-vba

我认为这很常见,我找不到它。我只是不知道如何调用它,但我基本上想要这样做:

Worksheets("JIRA EXPORT").Cells(x, 5).Value <> "Closed" or Worksheets("JIRA EXPORT").Cells(x, 5).Value <> "Resolved"

简而言之:

Worksheets("JIRA EXPORT").Cells(x, 5).Value <> ("Closed" or "Resolved")

我从其他程序中了解到的,但我不知道该怎么做。任何帮助是极大的赞赏。非常感谢!

2 个答案:

答案 0 :(得分:0)

If Worksheets("JIRA EXPORT").Cells(x, 5).Value = "Closed" Or Worksheets("JIRA EXPORT").Cells(x, 5).Value = "Resolved" Then
    MsgBox "Test Postivie"
Else
    MsgBox "Test Negative"
End If

Select Case Worksheets("JIRA EXPORT").Cells(x, 5).Value
    Case "Closed", "Resolved"
        MsgBox "Test Positive"
    Case Else
        MsgBox "Test Negative"
End Select

答案 1 :(得分:0)

您可以使用一些数组函数来执行查找:

If IsError( Application.Match(Worksheets("JIRA EXPORT").Cells(x, 5).Value, _
Array("Closed", "Resolved"), False)) Then
    ' Concluding test code
Else
    ' Not concluding test code
End If