Sub, Public Sub or Private Sub?

Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Sub, Public Sub or Private Sub?

  1. #1
    Board Regular
    Join Date
    Nov 2002
    Posts
    83
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Sub, Public Sub or Private Sub?

     
    I'm confused about Sub, Public Sub and Private Sub.

    I've got a macro that protects certain sheet, hides certain sheets and protects the workbook. I also have another that that unhides and unprotects them all. They can be launched by keying Cntrl+j and Cntrl+Shft_J, respectively. Right now they code resides in Module 5 and thus far work perfectly.

    But both are not Private Subs so they can be seen by a user in the macro box. If I make them Private they won't run. Is there a way to make these macros executable and NOT be seen in the macro box?

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Sub = Public Sub

    Private Sub makes it available to other macros in the same module, but not to the user

    To do what you want put (Hopes this doesn't confuse you even more)

    Option Private Module

    at the top.

    But remember, the user won't see the macro in the macro list, but if they write the macro's name, they'll be able to execute it.
    Regards,

    Juan Pablo González
    http://www.juanpg.com

  3. #3
    Board Regular
    Join Date
    Nov 2002
    Posts
    83
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    I love it...thanks for the info!

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com