+ Reply to Thread
Results 1 to 8 of 8

Workbook events and Worksheets events

  1. #1
    Forum Contributor
    Join Date
    06-14-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    186

    Workbook events and Worksheets events

    Hi,

    Can you call subs on Workbook events and Worksheet events from a sub in a normal module?

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Workbook events and Worksheets events

    You can, but there shouldn't be any need. If you need to do that, you should put the code into a routine in a normal module and call it from both the event procedure and the other code.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Workbook events and Worksheets events

    Yes, you can.

    Please Login or Register  to view this content.
    IMHO best practice is to create a Sub with whatever functionality you need to call from multiple places. Then if you have an event handler, call that Sub. Then call the same Sub from other places if needed. I prefer not to call event handlers of any type, but that is my personal preference.

    My preferred alternative:

    Please Login or Register  to view this content.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Contributor
    Join Date
    06-14-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    186

    Re: Workbook events and Worksheets events

    But you cannot call them from outside the current module they reside in

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Workbook events and Worksheets events

    You can, either using Application.Run or by making the event routines Public rather than Private.

  6. #6
    Forum Contributor
    Join Date
    06-14-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    186

    Re: Workbook events and Worksheets events

    can you show me an example please?

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Workbook events and Worksheets events

    Please Login or Register  to view this content.
    for instance. Again though, this is not the best way to do it.

  8. #8
    Forum Contributor
    Join Date
    06-14-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    186

    Re: Workbook events and Worksheets events

    Ok, cool, now I understand.
    Thank You xlnitwit

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Is it possible Enable one/few events, and disable rest of the events by VBA Excel?
    By hoalahpi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2016, 02:24 AM
  2. Help with Workbook Events
    By Utzja1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-11-2013, 09:29 AM
  3. [SOLVED] Excel VBA worksheets events priority
    By walduxas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-29-2012, 06:13 AM
  4. Two events in a workbook?
    By saeed9313 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-22-2008, 08:14 AM
  5. workbook events
    By Dennisli2000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2007, 11:14 AM
  6. workbook events
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2005, 05:05 AM
  7. Any mouse events for Worksheets?
    By InExcelHell in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-10-2005, 08:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1