+ Reply to Thread
Results 1 to 2 of 2

VBA Worksheet Protect

  1. #1
    Registered User
    Join Date
    05-26-2004
    Posts
    2

    VBA Worksheet Protect

    Dear All

    I have the following code that removes the protection from a worksheet and after performing a delete of certain cells protects the worksheet again. This code does not work when the worksheet is protected with a password. The password to the worksheet is the letter "a". How can I include the password in the code so that the protection is removed before the delete action and reinstated after the delete action


    ActiveSheet.Unprotect
    Range("C95:N95").Select
    Selection.ClearContents
    ActiveSheet.Protect

    Thanks
    Rodney Dsouza

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA Worksheet Protect

    Please edit your post above to include code tags, like shown below.

    No need to unprotect, just give the macro permission to edit the protected sheet by setting the UserInterfaceOnly flag.
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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