+ Reply to Thread
Results 1 to 4 of 4

Unlock only a range of cells on a locked sheet?

  1. #1
    Forum Contributor
    Join Date
    01-18-2013
    Location
    England
    MS-Off Ver
    2016 (Mac)
    Posts
    149

    Unlock only a range of cells on a locked sheet?

    Hello Everyone,

    I am looking for a macro that will unlock only a part of an already locked spread sheet? The sheet is password protected and will need to remain that way
    but I want the end user to be able to press a button that will activate a macro. The macro will only enable the following ranges to be edited (with the rest of the sheet remaining password protected):

    H9:L33, N9:Q15

    Everything else on the page will remain as it was before the button was pressed. The next time the button is pressed the sheet
    will be locked back to its original state.

    I am not sure to be honest if this is even possible but would appreciate any help / feedback.

    Margate

  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: Unlock only a range of cells on a locked sheet?

    Are you perhaps confusing the two separate processes of protecting a sheet and unlocking cells.

    Apologies if I'm teaching Grandma to suck eggs but when a sheet is protected all cells are locked by default unless specific cells have had their Protection 'Locked' format turned off. Can't you just unlock these H9:L33 & N9:Q15 cells.

    If you want a macro to unlock the cells then use

    Sub UnlockCells
    Sheets("MySheet").Unprotect Password = "MyPassword"
    Range("H9:L33","N9:Q15").Locked = False
    Sheets("MySheet").Protect Password = "MyPassword"

    End Sub

    but my sense is that you don't need a macro.
    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
    01-18-2013
    Location
    England
    MS-Off Ver
    2016 (Mac)
    Posts
    149

    Re: Unlock only a range of cells on a locked sheet?

    Hello Richard,

    Your right! It would not be relevant but I do not want anyone to have access to these cells normally in case they get over written and the formulas messed up. There is sensitive information elsewhere on the sheet that must remain password protected. I will try and find a way to let a user edit these cells without unlocking the whole sheet....
    Thank you very much for your help.

    Margate

  4. #4
    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: Unlock only a range of cells on a locked sheet?

    Hi,

    You appear to be saying that you want those cells protected MOST of the time, but on occasions you want someone to be able to edit them. Is that correct?

    If so the first thing I'd ask is what is it about the formulae in there that needs changing from time to time? If you explain this we may be able to offer a solution that doesn't need the user to enter the cells.

    Otherwise let us know what event should trigger the unlocking of the cells and what event should relock them. The act of moving to another sheet, or saving the workbook might be one such event - or perhaps a timer macro whereby they are locked x minutes after they are unlocked.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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