ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing arrays to VBA module (https://www.excelbanter.com/excel-programming/317435-passing-arrays-vba-module.html)

Ralph K

Passing arrays to VBA module
 
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?


Bob Phillips[_6_]

Passing arrays to VBA module
 
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)


"Ralph K" wrote in message
...
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?





All times are GMT +1. The time now is 06:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com