VBA Copying returning and passing arrays
Passing Arrays to Proceedures
Arrays can be passed to proceedures by putting () after the name of the array variable.
Arrays must be passed by reference. If no passing mechanism is specified, e.g. myFunction(arr()), then VBA will assume ByRef by default, however it is good coding practice to make it explicit. Trying to pass an array by value, e.g. myFunction(ByVal arr()) will result in an "Array argument must be ByRef" compilation error (or a "Syntax error" compilation error if Auto Syntax Check is not checked in the VBE options).
Passing by reference means that any changes to the array will be preserved in the calling proceedure.
If you want to avoid changing the original array then be careful to write the function so that it doesn't change any elements.
Alternatively create a working copy of the array and work with the copy.