Run a macro when sheet name changes

  • Thread starter Thread starter Kash
  • Start date Start date
hi
so far as i know, there is no sheet name change event to trigger a macro to
run.
what are we trying to do?

regards
FSt1
 
Do you mean when a user actually changes the name of a worksheet or when a
user selects a different worksheet.

If the former then I don't think there is an event associated with it.

If the latter then in the VBA editor on the left side there is the project
explorer.
Double click ThisWorkbook.

At the top of the section where the code goes there are 2 drop down boxes.
Click the DropDown arrow of the box on the left.
Click the dropdown of the box on the right.
Select either SheetActivate or SheetDeactivate.

The sub name and end sub will be created.

When writing the code, sh is the sheet that was either activated or
deactivated depending on which sub you use.
Example:
msgbox sh.Name 'Returns the sheet name
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top