Sub StartSub()The right solution to this problem is not always obvious, but there are a number of options at your disposal. Let's have a look...
Dim myValues() As Integer
' Fill the array
StopSub myValues
End Sub
Sub StopSub(otherValues As Integer)
MsgBox otherValues(2)
End Sub
Pass the array as a variant
This may not the best in terms of memory use, but makes things much easier if you ever need to change the size of the array in future coding. There is also a danger here of not knowing what type of data is being passed, but this should be simple to catch.
Sub StartSub()
Dim myValues() As Integer
' Fill the array
StopSub myValues
End Sub
Sub StopSub(otherValues As Variant)
MsgBox otherValues(2)
End Sub
Don't pass anything
This example
Dim publicValues() As Integer
Sub StartSub()
' Fill the array
StopSub
End Sub
Sub StopSub()
MsgBox publicValues(2)
End Sub
Pass the array as an array
Perhaps the most obvious solution, if not obvious in its implementation, is to accept an array in your second
Sub StartSub()
Dim myValues() As Integer
' Fill the array
StopSub myValues
End Sub
Sub StopSub(otherValues() As Integer)
MsgBox otherValues(2)
End Sub