Question

I would like to make a quick question and very basic on VBA...

I found this fine explanation on the web on VBA procedures:

Like a variable access, the access to a procedure can be controlled by an access level. A procedure can be made private or public. To specify the access level of a procedure, precede it with the Private or the Public keyword.

Next it goes as...

The rules that were applied to global variables are the same:

Private: If a procedure is made private, it can be called by other procedures of the same module. Procedures of outside modules cannot access such a procedure. Also, when a procedure is private, its name does not appear in the Macros dialog box

Public: A procedure created as public can be called by procedures of the same module and by procedures of other modules. Also, if a procedure was created as public, when you access the Macros dialog box, its name appears and you can run it from there

And its great, crystal clear! The only thing i wonder is what is the access level of a procedure declared without a Public or Private function?

minor question
Also if we have a Public keyword can the procedure by called by modules of other workbooks?

Thank you for seeing my question

Was it helpful?

Solution

Procedures are Public by default.

Procedures marked Public can be called by other workbooks unless you write Option Private Module at the top of the module containing the procedure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top