Hi, I built the following UDF and I need to do the following adjustments;
#adjustment 1: When my function returns a result greater to 7, the formula needs to return ">7" in the worksheet. I could handle this with a basic IF in the worksheet but I would need to go through my 100000+ rows...Is this possible to adjust the UDF without using IF statement either in the worksheet nor in the UDF?
#adjustment 2: When my array ends, the last result the formula returns in the worksheet is #VALUE . How can I handle this and by default returning 0 ?
Thank you in advance for all your answers !
#adjustment 1: When my function returns a result greater to 7, the formula needs to return ">7" in the worksheet. I could handle this with a basic IF in the worksheet but I would need to go through my 100000+ rows...Is this possible to adjust the UDF without using IF statement either in the worksheet nor in the UDF?
#adjustment 2: When my array ends, the last result the formula returns in the worksheet is #VALUE . How can I handle this and by default returning 0 ?
Thank you in advance for all your answers !
Code:
Function MyFunction(Par1 As Double, myArray)
myFunction = 0
Dim i As Variant
For Each i In myArray
If Par1 = 0 Then Exit Function
If Par1 < i Then
MyFunction = MyFunction + Par1 / i
Exit Function
Else
Par1 = Par1 - i
MyFunction = MyFunction + 1
End If
Next i
End Function