简体   繁体   中英

Excel-VBA Unite two logical statements

I think this is pretty common and I can't find it. I just don't know how to call this, but I basically want to make this:

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

Condensed down to something like this:

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

I made the top from what I know in other programs but I am not sure how to do this. Any help is greatly appreciated. Thanks a bunch!

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

or

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

You may use some array functions to execute a lookup :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM