mathsbeauty
Board Regular
- Joined
- Apr 23, 2011
- Messages
- 89
Here is the function. It works. It runs hundreds of times during some VBA procedure. Can the function be optimized? It accepts temparray as an array and identifies the first occurrence of "O", "A+" etc. in elements of array. I think it can be optimized as it compares tempArray(i) in every run of loop with "O", "A+" etc.
Any help will be appreciated. Thanks.
VBA Code:
function grade(tempArray)
For i = 0 To 10
If tempArray(i) = "O" Or tempArray(i) = "A+" Or tempArray(i) = "A" Or tempArray(i) = "B+" Or tempArray(i) = "B" Or tempArray(i) = "C" Or tempArray(i) = "D" Or tempArray(i) = "F" Then
grade = tempArray(i)
Exit Function
End If
Next i
grade = ""
end Function
Any help will be appreciated. Thanks.
Last edited: