Private Sub() - Sub()

C

CousinExcel

Hi,
I know only "record macro" way, then I edit that recorded macro.
And I see that they always start Sub()

I sometimes see in your solutions
macros starting as "Private Sub..."
How do we run such macros ?

Thanks,

Cousin Excel
 
J

Joe User

CousinExcel said:
I sometimes see in your solutions
macros starting as "Private Sub..."
How do we run such macros ?

Usually, such subroutines (and functions) are not intended to be executed
directly. They might be routines that support public routines, i.e. routines
that __are__ intended to executed directly.

But you can always go into VBA (press alt+F11), select the macro, and press
F5. You should not do that unless you know that the macro is intended to be
executed in that way.

I posted a Private Sub by mistake recently. I had intended to remove the
word Private.

Sometimes I have multiple experimental macros in different modules. Lacking
imagination, I might call all of them doit(). So I use the Private feature
to ensure that VBA does not get confused and raise an error. I don't need to
execute them from Excel because I am doing all my work in VBA.


----- original message -----
 

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

Similar Threads


Top