Results 1 to 4 of 4

Thread: Solved: What is the diffrence between Private Sub and just Sub in a macro

  1. #1
    VBAX Regular
    Joined
    Mar 2010
    Posts
    49
    Location

    Solved: What is the diffrence between Private Sub and just Sub in a macro

    I am new to VBA and do not know the difference between "Private Sub" and just "Sub" in a macro or where or when to use it, Any quick help please?

  2. #2
    VBAX Mentor
    Joined
    Apr 2009
    Location
    Kingsbury
    Posts
    421
    Location
    Hi Softman
    Save me explaining
    If you highlight the Sub or Private sub in a piece of code, then key F1 the microsoft help file will explain all.

    Rob

  3. #3
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,954
    Location
    A Sub is Public unless it set as Private. Private Subs are not listed in the macros that can be ran. These are usually set for you when you use an Event for example. Note the Userform code is Private for the objects since they have events. A Class typically has some Private Subs. A module can have a Private Sub if it is used just in that Sub. Most Module code is typically Public.

  4. #4
    VBAX Regular
    Joined
    Mar 2010
    Posts
    49
    Location
    Many thanks Kenneth, great explanation.

Posting Permissions

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