Retroshift
Board Regular
- Joined
- Sep 20, 2016
- Messages
- 119
- Office Version
- 2019
- Platform
- Windows
Hi, I would like to disable the option to delete, move, copy or rename one specific worksheet in a workbook, regardless of the activated worksheet in the workbook. I cannot protect the workbook structure, because I want to still be able to delete other worksheets in this workbook without the use of a password. I have this very basic VBA code, which does not seem to work. Anyone has an idea on how to make this code work?
VBA Code:
Private Sub DisableWorksheetChanges()
ThisWorkbook.Worksheets("NameOfSheet").Activate
Application.CommandBars.FindControl(ID:=847).Enabled = False 'Disable "delete worksheet" option
Application.CommandBars.FindControl(ID:=848).Enabled = False 'Disable "move or copy worksheet" option
Application.CommandBars.FindControl(ID:=889).Enabled = False 'Disable "rename" option
End Sub