Reputation: 11
If vOverfly(arrayIndex, 10) <= 0 And vOverfly(arrayIndex, 7) = "CCYN" And Trim(vOverfly(arrayIndex, 3)) <> "--" Then
resultCounter = resultCounter + 1
What do I need to do to add additional data to this line of code. Currently this line copies data where a number is <= 0 and is identified by CCYN. I am needing to know if other parameters fall below 0 such as "EOTN", "EOTH" and "CCYV". When I try to add these parameters it just ends up copying everything regardless of the number. Thanks.
Upvotes: 1
Views: 28
Reputation: 29352
And vOverfly(arrayIndex, 7) = "CCYN"
Try replacing the above part of code with this:
And IsNumeric (Application.match(vOverfly(arrayIndex, 7), _
Array("CCYN", "EOTN", "EOTH", "CCYV"), 0))
If this code is inside a loop, you can make it faster by defining the array of values to match only once:
Dim arValues
arValues = Array("CCYN", "EOTN", "EOTH", "CCYV")
...
If vOverfly(arrayIndex, 10) <= 0 And _
IsNumeric (Application.match(vOverfly(arrayIndex, 7), arValues, 0)) _
And Trim(vOverfly(arrayIndex, 3)) <> "--" Then
resultCounter = resultCounter + 1
Upvotes: 1
Reputation: 8270
you need to use brackets around your OR test for CCYN, EOTN,EOTH etc.
Sub Test()
If vOverfly(arrayIndex, 10) <= 0 And (vOverfly(arrayIndex, 7) = "CCYN" Or vOverfly(arrayIndex, 7) = "EOTN") And Trim(vOverfly(arrayIndex, 3)) <> "--" Then
resultCounter = resultCounter + 1
End Sub
Upvotes: 1