Scope of private function

O

oscar.c.marin

I have declared a private function in a VBA Module, but a get a "Sub or
Function not defined" error when called from a UserForm.

Any ideas?

Thanks in advance.

Oscar
 
B

Bob Phillips

That is because the scope is restricted to the module that the private
procedure is within.

To make it available to another module it must be Public. You can have the
procedures public but private to the project (that is not accessible from
another project, and not in the macros list in Excel), by making the
procedure public and by adding the phrase Option Private Module to the
module declarations at the start.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top