LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I have had difficulty in creating user defined functions in Excel MichaelG Excel Worksheet Functions 3 July 13th 05 11:59 AM
Default User Defined Functions - How? flycast Excel Discussion (Misc queries) 4 May 26th 05 04:26 AM
User Defined Functions Jeff B Excel Worksheet Functions 1 April 27th 05 09:59 PM
User Defined Functions Frank@shell Excel Worksheet Functions 3 April 20th 05 02:41 PM
I have user defined functions in sprdsheet. I want to put sprdsh. hjyoungii Excel Worksheet Functions 4 April 1st 05 10:48 PM


All times are GMT +1. The time now is 06:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"