Consulting

Results 1 to 5 of 5

Thread: How to Prevent Insertion / Deletion of Worksheet

  1. #1

    How to Prevent Insertion / Deletion of Worksheet

    Hi All

    Is there any method to prevent Insertion of a new worksheet or Deletion of an existing worksheet in a Workbook.

    Any help shall be well received.

    Thanx/r_mundhra

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    For insert, you could trap the NewSheet event and just delete it again.

    Delete is not easy, there is no event to piggy-back onto.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    By protectiting the WB(Tools\Protect\Protect Workbook), insertion/deletion of Wsheet can be done.

  4. #4
    Thanx Sujit for the info...I tried to generate the VBA code with the help of the Macro Recorder. I had put in a password also in the WB(Tools\Protect\Protect Workbook) pop up window. But the Macro (generated from recorded) does not show any password.
    Any help on this ...???
    Thanx/RM

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Sub DoProtect()
    ActiveWorkbook.Protect "password"
    End Sub

    Sub UnProtect()
    ActiveWorkbook.UnProtect "password"
    End Sub


    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •