macro naming syntax

hanasamo

Board Regular
Joined
May 31, 2005
Messages
83
VBA programming is a whole new world to me, I've noted that there are three kinds of macro naming syntax which are "sub macro_name()", "private sub macro_name()" and "public sub macro_name()". Is there any difference between those 3?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi

Firstly, the examples you give are not naming conventions for macros, they look like macros that have been converted to VBA.

Secondly, with regards to the naming conventions. The word (or lack of) in front of "sub macro_name" defines the scope of the function/sub-routine/variable etc (basically the scope defines what can reference/call the sub/function/variable).

For example:

Public Sub MySub() - this sub could be called from anywhere in your database project.

Private Sub MySub() - this sub can only be called from within the same module

Sub MySub() - defaults to Public access - see above.

Take a look in the help file under "Scope" if this isn't clear enough.

Hope that helps
Martin
 
Upvote 0

Forum statistics

Threads
1,219,165
Messages
6,146,681
Members
450,706
Latest member
LGVBPP

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top