ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet name (https://www.excelbanter.com/excel-programming/323863-worksheet-name.html)

xlcharlie

Worksheet name
 
Anybody know some event code I could use to execute should a user try to
change the name of a worksheet? I wrote a macro that won't work if it gets
lost in the workbook (if someone changes the worksheet names) so I want to
somehow protect the current names. I tried worksheet_change, but that only
seems to execute if a cell in the worksheet is changed. Thanks.

Tom Ogilvy

Worksheet name
 
If you protect the Workbook (structure option as a minimum) then the user
won't be able to rename, delete, add or change the order of sheets.

--
Regards,
Tom Ogilvy


"xlcharlie" wrote in message
...
Anybody know some event code I could use to execute should a user try to
change the name of a worksheet? I wrote a macro that won't work if it

gets
lost in the workbook (if someone changes the worksheet names) so I want to
somehow protect the current names. I tried worksheet_change, but that

only
seems to execute if a cell in the worksheet is changed. Thanks.




Doug Glancy

Worksheet name
 
You could also use the code name of the worksheet. It's shown in the
Project Explorer to the left of the tab name (the one displayed on your
worksheet) and in the Name property of the Properties window for the sheet.
Originally both the tab and the code name are the same, e.g., "Sheet1." You
can change the code name in the Name property in the Properties Window. It
doesn't change if users change the tab name. Use the code name like this:

Sheet1.Range("A1") = "test"

For more info see VBA help for "CodeName Property."

hth,

Doug Glancy

"xlcharlie" wrote in message
...
Anybody know some event code I could use to execute should a user try to
change the name of a worksheet? I wrote a macro that won't work if it

gets
lost in the workbook (if someone changes the worksheet names) so I want to
somehow protect the current names. I tried worksheet_change, but that

only
seems to execute if a cell in the worksheet is changed. Thanks.





All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com