To pass a value but retain the original value no matter what happens in the called Sub, use ByVal in the called Sub: Ex: Sub Message(ByVal iname As String, ino As Integer) [In this example, the original is retained, but may be iname ino changed by the called Sub.] Message Running a Sub When a Workbook Opens Use a Private Sub called Workbook_Open saved under the item in “ThisWorkbook” to have code automatically run Project Explorer when the file is opened. .For example, to ensure that the file always opens in a specific worksheet called “Explanation”: Ex: Private Sub Workbook_Open() Worksheets(“Explanation”).Activate End Sub
To pass a value but retain the original value no matter what happens in the called Sub, use ByVal in the called Sub: Ex: Sub Message(ByVal iname As String, ino As Integer) [In this example, the original iname is retained, but ino may be changed by the called Message Sub.] Running a Sub When a Workbook Opens Use a Private Sub called Workbook_Open saved under the “ThisWorkbook” item in Project Explorer to have code automatically run when the file is opened. .For example, to ensure that the file always opens in a specific worksheet called “Explanation”: Ex: Private Sub Workbook_Open() Worksheets(“Explanation”).Activate End Sub
MgtOp-470-Topic-3-Set-3.docx