+ Reply to Thread
Results 1 to 6 of 6

Macro to unprotect sheet --> unlock cells --> protect again

Hybrid View

  1. #1
    Registered User
    Join Date
    11-11-2010
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    11

    Macro to unprotect sheet --> unlock cells --> protect again

    I've done quite a bit of research, but can't find exactly what I'm looking for. I have a protected worksheet named "Data" which has certain locked cells. The password to unprotect is "Password". I've created a macro to copy from another file (which works great thanks to many of you!) At the end of the macro, I need to unprotect the sheet, unlock cells C13:L1012, then protect it again.

    I believe this is possible, right?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to unprotect sheet --> unlock cells --> protect again

    Hi,

    With Sheets("Data")
       .Unprotect Password:="Password"
       .Range C13:L1012.Locked = False
       .Protect Password:="Password"
    End With
    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    04-21-2007
    Location
    Lima, Peru
    MS-Off Ver
    2000, 2007, 2010
    Posts
    674

    Re: Macro to unprotect sheet --> unlock cells --> protect again

    Hi

    You need to add three lines of code, however if your sheet is already unprotected omit line 1.

    Sheets("Data").Protect "Password"
    Range("C13:L1012").Locked = False
    Sheets("Data").Protect "Password"
    Regards

    Jeff

  4. #4
    Registered User
    Join Date
    11-11-2010
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Macro to unprotect sheet --> unlock cells --> protect again

    Thank you guys very much! Sorry I didn't reply sooner, I was put on another job.

    The macro works great now!

  5. #5
    Registered User
    Join Date
    01-01-2011
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Macro to unprotect sheet --> unlock cells --> protect again

    i forgate my micro password

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Macro to unprotect sheet --> unlock cells --> protect again

    @608339, please note:

    a) do not post questions in the thread of another member (create your own thread and if relevant [not here] post a link to the other thread)

    b) we will not answer questions regarding circumvention of security

    both of the above are clearly outlined in the Forum Rules (please read them)

+ 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