Example:

Every macro must have a name (of course!). The name of the macro will be in the beginning Sub. The format is like following:
Sub <Macro Name>()
Example:
Sub Macro_Satu()
Sub Report()
Sub RunAll()
Sub Primary()
In the screenshot above, the macro name is Macro_1. You can put in what ever name you wish. A name is required else the macro will not run.Example:
Sub Macro_Satu()
Sub Report()
Sub RunAll()
Sub Primary()
When you create any Subs, it will also appear in the Macro prompt.

Please note that the macro name cannot have any space between them. The name must be one single word. If it is multiple words, you would need to use underscore _ .
Example:
Cannot
|
Can
|
Macro Satu
|
Macro_Satu
|
Run This Report
|
Run_This_Report
|
Report 1
|
Report_1
|
In any workbook, there can be multiple macros. Each must have a unique name or the computer get's confused on which macro to run.

This example shows two macros in the workbook which are Macro_1 and Macro_2. In the Macro prompt, it would appear like below:

The Macro prompt will enable Users to select which macro to run. Hence it is advisable to always create names that Users can understand what the macro is for. Macros can of course be triggered from a button or a shape that you put into the sheet, but that will be covered in another post.
No comments:
Post a Comment