+ Reply to Thread
Results 1 to 4 of 4

VBA locking and unlocking cells in protected sheet

  1. #1
    Registered User
    Join Date
    11-24-2020
    Location
    ...
    MS-Off Ver
    2019
    Posts
    2

    Unhappy VBA locking and unlocking cells in protected sheet

    Hello, I have a struggle with this:

    Please Login or Register  to view this content.
    It's for a test and it is supposed to lock the answer cells when you type "done" in B18. It doesn't work when the sheet is locked, it gives me unable to change protection of the range class message, however when the sheet is unlocked it changes the state of the cell from locked to unlocked and vice versa, just as it should. I am quite new to VBA and I have no idea if it is even possible to do. Could anyone help me? Thanks.

  2. #2
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    365
    Posts
    17,176

    Re: VBA locking and unlocking cells in protected sheet

    If the sheet is protected you first have to unprotect it to change cell locks.

    Please Login or Register  to view this content.
    If there is a password you need to put the password in quotes after the Unprotect/Protect methods.

    Also I recommend updating the misleading indentation as shown.

  3. #3
    Registered User
    Join Date
    11-24-2020
    Location
    ...
    MS-Off Ver
    2019
    Posts
    2

    Re: VBA locking and unlocking cells in protected sheet

    Yes! It works now, thank you.

  4. #4
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    365
    Posts
    17,176

    Re: VBA locking and unlocking cells in protected sheet

    If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    If a member helped you solve your problem, consider adding to their reputation by clicking on the star icon addreputationiconsmall.jpg below their name.

+ 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. Locking / Unlocking Cells
    By almulder in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-23-2020, 04:00 PM
  2. Locking excel sheet without unlocking previously locked cells
    By ashileekay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-06-2012, 10:23 AM
  3. unlocking some cells on a protected sheet
    By Frank49 in forum Excel General
    Replies: 1
    Last Post: 07-24-2012, 07:08 PM
  4. Locking and unlocking of cells
    By srinivassurapareddi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2012, 02:19 AM
  5. Locking/Unlocking Cells in Protected Worksheets
    By dteresinski in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2010, 08:26 AM
  6. Only allow locking of cells in a protected sheet
    By zarniuup in forum Excel General
    Replies: 2
    Last Post: 08-30-2010, 02:53 PM
  7. Locking and Unlocking Cells
    By vikas.bhandari in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2010, 10:27 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