Unlocking a Sheet for Update, then Relocking
Posted on 2010-09-24
I have a subroutine that refreshes a spreadsheet (Mod), by taking an exact image of the original, yet another sheet (Master) and replacing the modified spreadsheet (Mod). Pretty simple. Now I go to lock certain cells in the master. When I replace the Mod sheet with the subroutine, I now have the protected cells (which I want) in the Mod. sheet. When I do it a second time, it won't allow for it because I have protected certain cells that are now in Mod. Past EE answers to a similar question yielded the following:
ActiveSheet.EnableSelection = xlUnlockedCells
This routine was to allow for the use of Outlining on a protected sheet. I need a similar capability to unlock and relock cells when using my subroutine that updates the sheet. I think this may be a single line change (ActiveSheet.Outline.ShowLevels RowLevels:=Range("A").value) to reflect running my subroutine (Restore_range).
I hope this is clear and easy!