If vOverfly(arrayIndex, 10) <= 0 And vOverfly(arrayIndex, 7) = "CCYN" And Trim(vOverfly(arrayIndex, 3)) <> "--" Then
resultCounter = resultCounter + 1
我需要做些什么才能在此代码行中添加其他数据。目前,该行复制数字为&lt; = 0并由CCYN识别的数据。我需要知道其他参数是否低于0,例如“EOTN”,“EOTH”和“CCYV”。当我尝试添加这些参数时,它最终会复制所有内容而不管数字。谢谢。
答案 0 :(得分:1)
你需要在你的OR测试周围使用括号来进行CCYN,EOTN,EOTH等。
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
答案 1 :(得分:1)
R version 3.4.0 (2017-04-21) Platform: i386-w64-mingw32/i386 (32-bit) Running under: Windows 7 (build 7601) Service Pack 1 Matrix products: default locale: [1] LC_COLLATE=English_India.1252 LC_CTYPE=English_India.1252 LC_MONETARY=English_India.1252 [4] LC_NUMERIC=C LC_TIME=English_India.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_3.4.0 tools_3.4.0
尝试用以下代码替换上面的代码部分:
And vOverfly(arrayIndex, 7) = "CCYN"
如果此代码在循环内,您可以通过定义仅匹配一次的值数组来加快速度:
And IsNumeric (Application.match(vOverfly(arrayIndex, 7), _
Array("CCYN", "EOTN", "EOTH", "CCYV"), 0))