LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to make a public function procedure with undefined number of r

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
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
Undefined function q Excel Programming 4 February 25th 06 03:47 AM
Make Function Public Andibevan[_2_] Excel Programming 3 June 30th 05 04:46 PM
# added to number in function procedure Erin[_5_] Excel Programming 2 April 27th 04 11:58 PM
Public/Procedure Variable Otto Moehrbach[_6_] Excel Programming 2 February 6th 04 04:58 PM
Declaring Public Procedure mac Excel Programming 3 December 3rd 03 05:01 PM


All times are GMT +1. The time now is 04:21 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"