Unlimited number of variables?

F

Faraz A. Qureshi

Sometimes you never know how many variables you would be needing to gather a
data.

For example, =SUM(Variable-1, Variable-2, ...., Variable-n)

How to declare the same in this regard? Any sample shall be appreciated.
 
F

Faraz A. Qureshi

Sorry Jacob but the picture's still unclear. Buddy, can you please simply
design a simple sum type of a function like:

=XSUM(Variable-1, Variable-2, ...., Variable-n)

With a ReDim statement used?

Thanx again,
Best Regards,

Faraz
 
D

Dana DeLouis

Sometimes you never know how many variables you would be needing...

Hi. You may be looking for the ParamArray option.
Example:

Function MySum(ParamArray v() As Variant)
MySum = WorksheetFunction.Sum(v)
End Function

Sub TestIt()
Debug.Print MySum(1, 2, 3)
Debug.Print MySum(1, 2, 3, 4, 5, 6)
End Sub

= = = = = = = = = =
HTH :>)
Dana DeLouis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top