Passing Array into a function

axg275

Active Member
Joined
Oct 5, 2004
Messages
308
Hello,

I have a question that I need help with.

I made an array which is a one dimentional with 20 elements.

For i = 1 to 20
Array(i) = i
Next i
Now I want to feed this array into a function, do you know what I need to do?

I tired

x = funct(array) <== that did not work it only took in 1st element

also tried

x = funct(Range(array)) <== that did not work either.

I am all out of Ideas...

Can someone help me?

Thank you
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
It might help to see the actual function.
Code:
Sub test()
Dim arr(20)
    For i = 1 To 20
        arr(i) = i
    Next i
    
    MsgBox Myfunc(arr())
    
End Sub
Function Myfunc(a())
    For i = LBound(a()) To UBound(a())
        Myfunc = Myfunc + a(i)
    Next i
End Function
 
Upvote 0
This is what I actually have:

For i = 1 To 20

IPRpress(i) = DoGet("PROSPER.OUT.INF.Results[0][0][0].IPRpres[" & i - 1 & "]")
LiqRate(i) = DoGet("PROSPER.OUT.INF.Results[0][0][0].LiqRate[" & i - 1 & "]")


Range("J27").Offset(i, 0) = IPRpress(i)
Range("I27").Offset(i, 0) = LiqRate(i)

Next i

z = Utility.Terp(TestBHP, Range(IPRpress()), Range(LiqRate()))
 
Upvote 0
I thought you were dealing with a UDF.

DoGet and Terp must be part of an add-in or something.

They might not be set up to accept arrays.

Do you really need to use pass an array?

Couldn't you just run through the array, pass the individual items and return the results to another array.:)
 
Upvote 0

Forum statistics

Threads
1,214,970
Messages
6,122,514
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top