View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Run a macro when sheet name changes

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

--
Regards,

OssieMac


"Kash" wrote:

I need to run a macro when sheet name changes.. how to do this?