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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
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
 

axg275

Active Member
Joined
Oct 5, 2004
Messages
308
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()))
 

axg275

Active Member
Joined
Oct 5, 2004
Messages
308
It only brings in 1st element of the excel if I do it Norie's way
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
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.:)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,157
Messages
5,835,713
Members
430,381
Latest member
tntcute

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
Top