+ Reply to Thread
Results 1 to 12 of 12

Event triggered when renaming sheet?

Hybrid View

  1. #1
    Registered User
    Join Date
    07-25-2008
    Location
    Tucson, AZ
    Posts
    90

    Event triggered when renaming sheet?

    I need to declare an event that happens when a worksheet is renamed

    the code that would trigger the event is

    ActiveSheet.Name = NewName
    it looks like VBA does not have any such thing built-in

    are there any other options?

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    If your code is renaming the sheet, why not just call whatever procedure you want to execute when you do it?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    07-25-2008
    Location
    Tucson, AZ
    Posts
    90
    actually it's not my code that's renaming the sheet - it's code from a commercial XLA add-in that I'm interacting with. I need to recognize when the Add-In renames a sheet and execute my code when that happens

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    There is indeed no such event.

    Depending on why you need to know that the sheet is renamed, there may be alternatives.

  5. #5
    Registered User
    Join Date
    07-25-2008
    Location
    Tucson, AZ
    Posts
    90
    I need to know that the sheet has been renamed because it tells me what type of data has been input to the sheet. It also tells me that the Add-In is finished writing data to the sheet because renaming is the last action it performs before finishing the subroutine.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    So check the name of the sheet before you do anything that depends on its contents ...

    And you know the add-in is done when your code execution resumes, because VBA is single-threaded.

  7. #7
    Registered User
    Join Date
    07-25-2008
    Location
    Tucson, AZ
    Posts
    90
    the problem is that I don't want to start executing my code until I'm sure that the add-in has finished.

    Once my code has started, I can check the name of the sheet to determine what to do with it, but I can't start running my code until I'm sure that no more data will be written to that sheet

    hope that makes sense

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    What triggers the add-in?

  9. #9
    Registered User
    Join Date
    07-25-2008
    Location
    Tucson, AZ
    Posts
    90
    the user triggers the addin

    it has a custom menu in the excel toolbar. by clicking through the menus and some dialog boxes, the user defines what type of Designed Experiment should be populated on the new sheet. Then the add-in creates that DOE experiment and populates the data onto the new sheet. finally the sheet is renamed at which point I want my code triggered to copy the data from the new sheet into various locations in other sheets

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    You could shadow the button click event, and then start an OnTime procedure that checks the name of the sheet periodically (the first invocation may not run until the add-in is complete).

    Or give the user another button to trigger your code.

    Sorry, I don't have a better idea.

  11. #11
    Registered User
    Join Date
    07-25-2008
    Location
    Tucson, AZ
    Posts
    90
    is the click event you refer to associated only with UserForms?

    the addin doesn't use a UserForm, but instead some type of dialog box

    does this click event work for these dialog boxes too?

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    If you get the ID of a button (the add-in's button, in this case), you can process then event in your code as well -- I think . I don't do a lot of work with menus -- Andy Pope, RoyUK, or some others could do this in their sleep.

    Given the number of exchanges in this thread, I'd suggest you start a fresh one, something like "Shadow click event for menu button"

+ 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. How to assign a number to a cell in another sheet by clicking an object?
    By karat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-27-2007, 04:02 AM
  2. Reading "data" in a sheet and applying to another sheet
    By kollinsb in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-04-2007, 10:38 AM
  3. Links in same spreadsheet problem
    By dyun1dyun1 in forum Excel General
    Replies: 4
    Last Post: 04-21-2007, 12:17 AM
  4. BeforeDoubleClick Event on Protected Sheet
    By jasoncw in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2007, 09:12 PM
  5. I can't unhide sheet
    By florinicolau in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-23-2007, 05:51 AM

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