ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code so that worksheets cannot be added to workbook (https://www.excelbanter.com/excel-programming/440127-code-so-worksheets-cannot-added-workbook.html)

D

Code so that worksheets cannot be added to workbook
 
Does anyone know if it is possible to have a code in the background that will
not let users add worksheets to a workbook? If so, how would this be done?

FSt1

Code so that worksheets cannot be added to workbook
 
hi
personally i don't know how you can prevent users from adding new sheets but
you can delete them as fast as they are added.

Private Sub Workbook_NewSheet(ByVal Sh As Object)
MsgBox "new sheet are prohibited."
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
End Sub

regards
FSt1

"D" wrote:

Does anyone know if it is possible to have a code in the background that will
not let users add worksheets to a workbook? If so, how would this be done?


D

Code so that worksheets cannot be added to workbook
 
This is awesome!! Works great. Perfect for those workbooks that users are
having to paste data to that is linked to say another workbook or program.

Thanks!

"FSt1" wrote:

hi
personally i don't know how you can prevent users from adding new sheets but
you can delete them as fast as they are added.

Private Sub Workbook_NewSheet(ByVal Sh As Object)
MsgBox "new sheet are prohibited."
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
End Sub

regards
FSt1

"D" wrote:

Does anyone know if it is possible to have a code in the background that will
not let users add worksheets to a workbook? If so, how would this be done?


Dave Peterson

Code so that worksheets cannot be added to workbook
 
You could protect the workbook's structure.

But that will prevent new sheets, moving existing sheets, deleting sheets,
renaming sheets...

In xl2003 menus:
tools|protection|protect workbook



D wrote:

Does anyone know if it is possible to have a code in the background that will
not let users add worksheets to a workbook? If so, how would this be done?


--

Dave Peterson


All times are GMT +1. The time now is 11:01 PM.

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