Looking at Sub procedures

Every Sub procedure starts with the keyword Sub and ends with an End Sub statement. Here's an example:

Sub ShowMessage()

MsgBox "That's all folks!" End Sub

This example shows a procedure named ShowMessage. A set of parentheses follows the procedure's name. In most cases, these parentheses are empty. However, you may pass arguments to Sub procedures from other procedures. If your Sub uses arguments, list them between the parentheses.

When you record a macro with the Excel macro recorder, the result is always a Sub procedure.

As you see later in this chapter, Excel provides quite a few ways to execute a VBA Sub procedure.

0 0

Post a comment