ParamArrays Cannot Be Passed by Reference

In Microsoft Excel variables are passed by reference (ByRef) by default; however, you may pass them by value (ByVal). The following code will work in Microsoft Excel 95:

Sub Hello()
   x = ShowMessage("hi there", 0)
End Sub

Function ShowMessage(szMessage As String, iButtons As Integer, ParamArray       vaSubText() As Variant) As Integer
    Dim szFinalMessage As String
    szFinalMessage = SubstituteText(szFinalMessage, vaSubText)  
End Function

Function SubstituteText(szMessage As String, vSubText As Variant) As String
SubstituteText = szMessage
End Function

This code will not work in Microsoft Excel 97 as ParamArrays must be passed by value (ByVal). This indicates that the sub or procedure may have access to a copy of the variable but may not change the value of the variable. The workaround for Microsoft Excel 97 is:

Function SubstituteText(ByVal szMessage As String, vSubText As Variant) As String
SubstituteText = szMessage
End Function