Home |
Search |
Today's Posts |
#4
![]() |
|||
|
|||
![]()
It was an example Harlan, one step at a time.
Bob "Harlan Grove" wrote in message oups.com... Bob Phillips wrote... ... If you really want a variable number of arguments, then somthing like Function mySum2(ParamArray inVal()) Dim temp Dim i As Long For i = LBound(inVal()) To UBound(inVal()) If IsNumeric(inVal(i)) Then temp = temp + inVal(i) End If Next i mySum2 = temp End Function ... Since when can variable numbers of arguments only consist of scalars? If you're going to do this right, accept variable numbers of scalar, range and array arguments. Function mysum(ParamArray a()) As Double Dim x AS Variant, Y As Variant On Error Resume Next For Each x In a If TypeOf x Is Range Then For Each y In x.Cells mysum = mysum + CDbl(y.Value) Next y ElseIf IsArray(x) Then For Each y In x mysum = mysum + IIf(IsArray(y), mysum(y), CDbl(y)) Next y Else mysum = mysum + CDbl(x) End If Next x End Function Doing the latter right eliminates the need for the former. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I have had difficulty in creating user defined functions in Excel | Excel Worksheet Functions | |||
Default User Defined Functions - How? | Excel Discussion (Misc queries) | |||
User Defined Functions | Excel Worksheet Functions | |||
User Defined Functions | Excel Worksheet Functions | |||
I have user defined functions in sprdsheet. I want to put sprdsh. | Excel Worksheet Functions |