Consulting

Results 1 to 5 of 5

Thread: VBA

  1. #1

    Thumbs down VBA

    Hi all,

    can anybody suggest that what is the difference between writing VBA code in worksheet code window and module code window.

    suggestions will be appreciated.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    The worksheet code module is to hold code that would pertain directly to that sheet, usually triggered b y some worksheet event.

    The standard code module is more generic, and can be used by procedures in This Workbook, a worksheet, a form, a class, or just other procedures in standard code modules.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    There is a very big differenece, and that difference has to do with the scope of the code.

    Code behind a worksheet is only available for use by that worksheet, but code placed into a module can be called from any worksheet.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Threads merged, anandbw82 please only post one thread per question.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by CreganTur
    Code behind a worksheet is only available for use by that worksheet, but code placed into a module can be called from any worksheet.
    Not absolutely correct, you can access a procedure in a worksheet code module if it is public in scope byh preceding with the worksheet codename.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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