Pass a Variable List Of Values To Subroutine or Function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All,

What I want to do is create a function (maybe subroutine) that will be
passed a variable number of values and perform some processing. I am not
sure this is possible because the functions I have created in the past has a
finite number of parameters.

Has anyone done this?

Thanks in advance.

Dean.
 
I do this frequently. Look at "Understanding Parameter Arrays" in VBA
Help
 
Take a look at ParamArray in VBA help, just what you need. Here is a simple
example

Public Function weightedstdev(ParamArray rng())
Dim rngCount
rngCount = UBound(rng, 1)
For i = 0 To rngCount
' your code
Next
End Function


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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

Back
Top