Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am making a user defined function in Excel that takes an unlimited amount
of ranges as input. How shall I do this? I have figured out that a one range function could be as follows: Public Function MySum(MyRange As Range) As Double The question now is how to make a function with an unlimited amount of ranges and to be able to uses these ranges in a function. Could someone please illustrate how to do this by e.g. replicating the Sum function in excel? The following code is only summing one range, how should it be changed to take in unlimited ranges? Public Function MySum(MyRange As Range) As Double Dim i As Integer Dim Temp As Double Dim rows As Integer Dim columns As Integer rows = MyRange.rows.Count columns = MyRange.columns.Count For i = 1 To columns Temp = Temp + MyRange(1, i) Next For i = 1 To rows Temp = Temp + MyRange(i, 1) Next MySum = Temp End Function Thanx -- Melwin |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Undefined function | Excel Programming | |||
Make Function Public | Excel Programming | |||
# added to number in function procedure | Excel Programming | |||
Public/Procedure Variable | Excel Programming | |||
Declaring Public Procedure | Excel Programming |