return an array of values from a function procedure

karthikone

New Member
Joined
May 4, 2006
Messages
19
hi,

i want to know how to return an array of values from a function and use that array values in the calling procedure.

say for eg.


Sub XYZ()

---
---
---

Select Case C

Case "ABC"

Call Gap(arg, arg2, arg3, arg4, arg5)

End Select

End Sub



Function Gap(Par1, Par2, Par3, Par4, Par5)

---
--
--


End Function

I want to return 4 values from the called procedure to the calling procedure. In the calling procedure i want to assign the values which is computed from the called procedure to a variable.


How to do it.


Any help.

thanks[/code]
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
karthik.

here is a simple example:

Code:
Sub Example()

    Dim aryExample()
    
    aryExample = ArrayFunction("Element 1", "Element 2")
    
    For i = LBound(aryExample) To UBound(aryExample)
        MsgBox aryExample(i)
    Next i
    
End Sub

Private Function ArrayFunction(arg1, arg2)

    ArrayFunction = Array(arg1, arg2)
    
End Function

cheers. ben.
 
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,647
Members
449,325
Latest member
Hardey6ix

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