Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing array to functions byref
Hi i am new to excel programing can any body help me in knowing how to pass
an array to function byref. i need this very badly Thanks in advance |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing array to functions byref
Sub main()
Dim a(5, 5) y = PassArray(a) End Sub Function PassArray(ByRef a()) b = a(5, 1) End Function "kris" wrote: Hi i am new to excel programing can any body help me in knowing how to pass an array to function byref. i need this very badly Thanks in advance |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing array to functions byref
Joel has shown you the code.
However, as ByRef is the default in VB/VBA, you can omit it. Also, if you try to change the function signature to ByVal instead, you will get a compile error "Array argument must be ByRef". So your array will always be byref anyway. Note that if the array is in a Variant, then all the normal ByRef/ByVal considerations apply. e.g. Private Sub CommandButton1_Click() Dim a(5, 5) a(5, 1) = "Original" PassArray (a) Debug.Print a(5, 1) PassArray a Debug.Print a(5, 1) End Sub Function PassArray(ByRef a As Variant) a(5, 1) = "New value" End Function NickHK "kris" wrote in message ... Hi i am new to excel programing can any body help me in knowing how to pass an array to function byref. i need this very badly Thanks in advance |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing array to functions byref
"kris" wrote: Hi i am new to excel programing can any body help me in knowing how to pass an array to function byref. i need this very badly Thanks in advance Thanks again Joel and NickHK |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
passing range to function: type of argument is byref incompatible | Excel Programming | |||
Templates and passing functions | Excel Programming | |||
passing targets between functions | Excel Programming | |||
passing arrays between functions in VBA | Excel Programming | |||
ByRef not passing address | Excel Programming |