Hello Roccofan.
The quick way to do this is to go to Tools / Protection / Workbook. You may use a password or just click OK without using a password. This will take away the right-click option and the Format / Rename options to rename the worksheet tab.
Write some code in the Workbook before close event that will cycle through the sheets. Then in the sheet activate events check the sheet name and change it back if it has been changed.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
For Each sht In Worksheets
sht.Activate
Next
'//Cycle thrugh twice to get al sheets
For Each sht In Worksheets
sht.Activate
Next
End Sub
This in each sheet you want to protect
Just change TEST to the name of the sheet
Private Sub Worksheet_Activate()
If ActiveSheet.Name <> "TEST" Then
MsgBox prompt:="This sheet must be named TEST", _
Title:="NOTICE"
ActiveSheet.Name = "TEST"
End If
As Viper and Steve have said, just protecting the workbook will protect the sheet name, you don't really need code for this as all sheet names will be protected anyway. You can also protect the workbook without protecting individual worksheets if you wish. This message was edited by Mudface on 2002-08-28 11:56
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.