View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] fisherofsouls@hotmail.com is offline
external usenet poster
 
Posts: 6
Default VBA: How to pass arrays in Function Calls?

More generally, make use of Paramarray to pass back and forth whatever
you like !

Example:

Put this in the declare space:

Public MyCols() 'Default to Variant data type;
also Cols is not a
'great idea for a
variable name as it is reserved to
'VB in many contexts

Then try the following procedures:

Function Testx(Arg)
' Function should return the word "Won".
Call Testy(MyCols())
Testx = MyCols(1)
End Function


Sub Testy(ParamArray MyCols() As Variant)
MyCols(1) = "Won"
MsgBox "Done" <-- Calling never gets to this line.
End Sub

Nick