[hh]:mm:ss is not a format that can be used with the vba format() function - yes, it works in Excel worksheets (
100:00:00 for 100 hours, which is decimal 4.1666667)
Anyone know what the brackets mean in the Excel custom format?
Regards your original post, vba format() returns a string and the format doesn't work so I can see why using a numeric return value fixes it - that's better anyway.
This would be a slightly simplified version of your formula, if you like:
Code:
Public Function SUMIFNOTERROR(ParamArray Values() As Variant) As Double
Dim v As Variant
On Error Resume Next
For Each v In Values
SUMIFNOTERROR = SUMIFNOTERROR + v
Next v
End Function
It is possible to use a range rather than a paramarray (by way of example - I started thinking about how to answer Hotpepper's question and this was what I came up with):
Code:
Public Function SUMIFNOTERROR2(arg As Range) As Double
Dim c As Range
On Error Resume Next
For Each c In arg
SUMIFNOTERROR2 = SUMIFNOTERROR2 + c.Value
Next c
End Function
But the syntax for using the formulas are different:
=SUMIFERROR(A1,A3,A5) <-- your formula with paramarray
=SUMIFERROR2((A1,A3,A5)) <-- version with a range argument instead
The first probably feels more natural and would be better understood for other users, I think, since you don't need the extra parens.