using vba code How to prevent sheet tab names means user can't change sheet name ?
using vba code How to prevent sheet tab names means user can't change sheet name ?
Protect the workbook (Review tab).
.
If you don't have a large number of sheets to protect you can place this macro into each SHEET MODULE. Obviously you will
need to change the sheet name in the macro to match the SHEET MODULE the macro is being pasted in.
Private Sub worksheet_SelectionChange(ByVal Target As Excel.Range) If ActiveSheet.Name <> "Master" Then '<--- edit sheet name to match existing name ActiveSheet.Name = "Master" '<--- edit sheet name to match existing name End If End Sub
If you're worried that users will change the name on the tab of a worksheet and that might cause a macro to break:
Worksheets ("Stores") subscript error because some user changed the name to Worksheets("Dept")
I'd change the code name that the user doesn't see to something and use that in my macros.
Then it doesn't matter is the user changes the name. You can always get it by using "Data.Name" in my example
Capture.JPG
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
.
Did you paste it into the Sheet Level Module ?
See attached.