Example. Arrays can be passed to proceedures by putting () after the name of the array variable. Function countElements(ByRef arr() As Double) As Long. This is fairly trivial, using the ByRef keyword in the function signature will pass your array by reference rather than by value. This means that. Arrays are a set of indexed elements for the same data type variable. Each element is independent but belongs to the same group variable and is better than . Unless you're passing it to a separate thread (e.g. COM server) and want to avoid marshalling cost, it's much cheaper to pass the array ByRef. Passing Arguments By Value. Passing Arguments By Reference. Optional Arguments. Pass an Arbitrary or Indefinite Number of Arguments - Parameter Arrays. It is possible to pass an array into a subroutine or function. Arrays are always passed in by reference (ByRef). This means that any changes to. “A list is only as strong as its weakest link” – Donald Knuth. The following table provides a quick reference to using arrays in VBA. The remainder of the post. use an explicit calling convention ByVal or ByRef for them. (arrays are called by reference within VBA),. • use explicit return types for functions. Use long instead. Array argument must be ByRef. 06/07/ Note that ByRef is the default. Have questions or feedback about Office VBA or this documentation?. You will receive a compiler error if you attempt to pass an array ByVal. (See the Online VBA Help for the topic Sub Statement for information about ByRef and.