Be the first user to complete this post
|Add to List|
Excel-VBA : Prevent Adding New Worksheet
Many a times you need a scenario where you dont want user to add new worksheets in you Excel work book.
Its quite easy to do.
- Go to VBA Editor
- Expand your VBA Project
- Double Click ThisWorkBook
- Now select the "Workbook" from the first drop down on the right
- Select the NewSheet from the second drop down on the right
- Now you will see the function Private Sub Workbook_NewSheet(ByVal Sh As Object).
- Add the following code in the function.
Application.DisplayAlerts = False
MsgBox "Sorry, Adding new Sheet is not allowed"
And thats it you are done. Lets test our program.
Go to excel and try adding a new worksheet.
- VBA-Excel: Working with Microsoft Word
- VBA-Excel: Modified Consolidator – Merge or Combine Multiple Excel Files Into One Where Columns Are Not In Order
- VBA-Excel: Open word document using GetObject()
- VBA-Excel: Cells Ranges Offset - Active Cell
- VBA-Excel: Get ALL The Opened Internet Explorer (IE) using Microsoft Excel
- VBA-Excel: Launch Mozilla Firefox using Microsoft Excel.
- VBA Excel - Cells, Ranges and Offset: Refer to Cells by Using Shortcut Notation
- VBA-Excel: Add/Insert multiple objects from a folder in an Excel Document.