Prevent Tabs /Sheets being added or deleted

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,338
Office Version
  1. 365
Platform
  1. Windows
Is there a way to prevent sheets from being deleted or added to a workbook?

Thanks
Greg in Orlando
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Prevent Tabs /Sheets from being added or deleted

Thanks, but I can't protect the workbook - its multi-user (Shared)
 
Upvote 0
What about protecting the workbook, then unprotecting all areas the users need to work in??

Just an idea,
Michael
 
Upvote 0
Taking away the menu items and the paths to them might do it for you.

Place this in your workbook module and see if it accomplishes what you are after. To easily access your workbook module, find the little Excel workbook icon near the upper left corner of your workbook window, usually just to the left of the File menu option. Right click on that icon, left click on View Code, and paste the following procedure into the large white area that is the workbook module. Press Alt+Q to return to the worksheet.


Private Sub Workbook_Activate()
With Application
.CommandBars("Worksheet Menu Bar").Controls("Edit").Controls("Delete Sheet").Enabled = False
.CommandBars("Worksheet Menu Bar").Controls("Insert").Controls("Worksheet").Enabled = False
.CommandBars("Toolbar List").Enabled = False
.CommandBars("Ply").Enabled = False
End With
End Sub


Private Sub Workbook_Deactivate()
With Application
.CommandBars("Worksheet Menu Bar").Controls("Edit").Controls("Delete Sheet").Enabled = True
.CommandBars("Worksheet Menu Bar").Controls("Insert").Controls("Worksheet").Enabled = True
.CommandBars("Toolbar List").Enabled = True
.CommandBars("Ply").Enabled = True
End With
End Sub


Save the workbook, then either
- close it and re-open it
or
- activate another Excel workbook (open in that instance of Excel) and re-activate the subject workbook
 
Upvote 0
Thank You One and All

Toms suggestion will do the trick. Thanks, I didnt think of that.

Greg
 
Upvote 0
Edit/Move or copy Sheet needs to be disabled too ... any idea how to add this to Tom's code ?
I understand that I will lose the option of moving or copying the sheet but in my situation the need to disable the adding/deleting or renaming a sheet is way more important.
Regards,
Nick
 
Upvote 0
This should do it:


Private Sub Workbook_Activate()
With Application
.CommandBars("Worksheet Menu Bar").Controls("Edit").Controls("Move or Copy Sheet...").Enabled = False
.CommandBars("Worksheet Menu Bar").Controls("Edit").Controls("Delete Sheet").Enabled = False
.CommandBars("Worksheet Menu Bar").Controls("Insert").Controls("Worksheet").Enabled = False
.CommandBars("Toolbar List").Enabled = False
.CommandBars("Ply").Enabled = False
End With
End Sub


Private Sub Workbook_Deactivate()
With Application
.CommandBars("Worksheet Menu Bar").Controls("Edit").Controls("Move or Copy Sheet...").Enabled = True
.CommandBars("Worksheet Menu Bar").Controls("Edit").Controls("Delete Sheet").Enabled = True
.CommandBars("Worksheet Menu Bar").Controls("Insert").Controls("Worksheet").Enabled = True
.CommandBars("Toolbar List").Enabled = True
.CommandBars("Ply").Enabled = True
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,596
Messages
6,120,438
Members
448,966
Latest member
DannyC96

We've detected that you are using an adblocker.

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.
Go back
Back
Top