Passing arrays to VBA module

  • Thread starter Thread starter Ralph K
  • Start date Start date
R

Ralph K

My experience with user defined functions has been limited to simple
procedures using individual data items as arguments. Now, I need to grab
a range of values from the SS, pass them to a function as one or more
arrays, read the arguments into local arrays withing the VBA procedure,
perform my process, and return the function value.

I need a simple illustration of this process but have had no luck with
the Excel/VBA help. Where should I look?
 
Here is a simple example

Function mySum(rng As Range) As Long
Dim ary
Dim i As Long
ary = rng
For i = LBound(ary) To UBound(ary)
mySum = mySum + ary(i, 1)
Next i
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

Similar Threads


Back
Top