I'm using Excel Version 1902, Build 11328.20392 within MS Office 365 ProPlus.
I call a function from a cell in a worksheet:
=addOnlyPositiveValues(D2, E2, F2,G2)
Only the first parameter is mandatory, the others are optional:
Function addOnlyPositiveValues(v01 As Range, Optional v02 As Range, Optional v03 As Range, Optional v04 As Range, Optional v05 As Range ) As Double
Dim dblRet As Double
dblRet = 0
dblRet = var2dbl_positiveOnly(v01.Value)
If Not (IsMissing(v02)) Then dblRet = dblRet + var2dbl_positiveOnly(CVar(v02.Value))
If Not (IsMissing(v03)) Then dblRet = dblRet + var2dbl_positiveOnly(CVar(v03.Value))
If Not (IsMissing(v04)) Then dblRet = dblRet + var2dbl_positiveOnly(CVar(v04.Value))
If Not (IsMissing(v05)) Then dblRet = dblRet + var2dbl_positiveOnly(CVar(v05.Value))
' If Not (IsMissing(v05) Or (v05 Is Nothing)) Then dblRet = dblRet + var2dbl_positiveOnly(CVar(v05.Value))
addOnlyPositiveValues = dblRet
End Function
This worked until recently (can't tell exactly when it starting to act up).
In my example above I don't set a 5th parameter.
I expect the function to skip the If Not (IsMissing(v05)) Then ...
. Stepping through the code I see that v05
is NOTHING
.
My workaround:
If Not (IsMissing(v05) Or (v05 Is Nothing)) Then ...