我想知道是否存在关于多个IF
语句序列的一般规则,并考虑OR
个语句和&
组合。
e.g。下面是我最初想到的最快方式
Dim DataRCntr As Long
Dim MyRange As Range
Dim Target As String
Dim DataArr() As Variant
Dim StrArr() As Variant
DataArr = MyRange.Value
StrArr = Array(Target, "High", "Major", Target & "High", Target & "Major")
For DataRCntr = LBound(DataArr, 1) To UBound(DataArr, 1)
If DataArr(DataRCntr, 4) & DataArr(DataRCntr, 11) = StrArr(2) Or _
DataArr(DataRCntr, 4) & DataArr(DataRCntr, 11) = StrArr(3) Then
If DataArr(DataRCntr, 20) < 0.9 Then
'Do Something
End If
End If
Next DataRCntr
我正在考虑的一些事情的例子:
IF
声明中,您可以将其拆分为两个,这样您首先检查DataArr(DataRCntr, 4)=StrArr(1)
以避免OR
声明,如果第一个匹配DataArr(DataRCntr, 4) & DataArr(DataRCntr, 11)
语句IF
的字符串
醇>