Consulting

Results 1 to 4 of 4

Thread: Worksheet activate code in Add-in

  1. #1

    Worksheet activate code in Add-in

    I have a spreadsheet (call it SS.xls) with a number of sheets (called, eg, "Notes","Archive"), and a separate add-in.

    I want to have some code in the add-in that is called when one of the sheets is activated. (separate modules for each of the sheets)
    Of course, I could have some code in SS.xls, but I want it all in the add-in, as there's going to be lots of versions of the spreadsheet, and I don't want to have to recall the spreadsheets if some code changes are needed.

    How can I get code in the add-in to tie in to the Worksheet_Activate event?
    I know I've done it before, but can't remember how I did it!

  2. #2
    can't you just create a sub in the add-in and call that sub from the worksheet_activate event? As long as the name of the sub never changes you will only have to modify the code in the add-in and not the actual .xls file.

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Either:

    in that activate event call the addin procedure directly using APplication.Run (documented in VBA Help)

    Or

    set a reference in the workbook to the addin and call the procedure directly.
    ____________________________________________
    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

  4. #4

    Solved

    Many thanks.

    I've used the Worksheet_Activate event to call the add-in sub, with complete success.

Posting Permissions

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