+ Reply to Thread
Results 1 to 4 of 4

VBA code to protect workbook

  1. #1
    Registered User
    Join Date
    06-01-2016
    Location
    Singapore
    MS-Off Ver
    13
    Posts
    55

    VBA code to protect workbook

    Hello,

    I have following code that will delete the sheet named kirok when the user selects the values in the drop down list from "yes" to "no". But the problem is its not protecting the workbook back post deletion. can you please suggest?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: VBA code to protect workbook

    I'm guessing it's hitting the Exit Sub in your loop and dropping out. Probably need Exit For there instead.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: VBA code to protect workbook

    Hi,

    The second Protect call is actually unprotecting the workbook again. There does not seem to be any need to unprotect unless you delete the sheet, so I would suggest amending your code accordingly:
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Registered User
    Join Date
    12-23-2014
    Location
    Milton Keynes, England
    MS-Off Ver
    360 / 2013
    Posts
    39

    Re: VBA code to protect workbook

    Glad i found this. I had a similar requirement and this worked a treat.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Complicated VBA code to protect the entire workbook (in a single step)
    By Anka in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-14-2015, 02:19 PM
  2. Protect VBA code in excel workbook that I exported
    By Goodstart14 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-09-2014, 01:50 PM
  3. [SOLVED] VBA code - Hide the Gridlines, Headlines, Formula line, Tabs and protect the workbook
    By gnaske in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 04-11-2014, 10:00 AM
  4. Protect/Unprotect a Workbook with code
    By RevJeff in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-17-2012, 10:22 AM
  5. How to protect desired area of workbook and protect code.
    By avveerkar in forum Excel General
    Replies: 4
    Last Post: 01-12-2006, 10:44 PM
  6. Replies: 6
    Last Post: 12-27-2005, 04:20 AM
  7. Replies: 5
    Last Post: 08-09-2005, 11:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1