I was wondering if there was a general rule regarding the sequence of several IF statements, taking ORstatements and & combination into consideration.
e.g. below is my initial thought about the fastest way
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_Current(DataRCntr, 20) < 0.9 Then
'Do Something
End If
End If
Next DataRCntr
Example of a few things i was thinking about:
- In first
IFstatement, you could split it up in two so you first check forDataArr(DataRCntr, 4)=StrArr(1)to avoid theORstatement if the first doesn't match - You could create a String combining
DataArr(DataRCntr, 4) & DataArr(DataRCntr, 11)before theIFstatement
Aucun commentaire:
Enregistrer un commentaire