I have some specific cells locked and others unlocked.
When I manually protect the worksheet, I cannot select the locked cells, which is what I am looking for. This is the correct behavior.
I have some code that runs when I open a workbook and when I close the workbook.
The code basically ensures that the worksheet is protected and only the options that I need available to the users are checked.
However, even though I have the EnableSelection:=xlUnlockedCells coded, it is not working.
When I open the file, it shows it is protected, yet I can select the locked cells, which I shouldn't be able to do.
If I then manually unprotect and then protect (all of the correct options are still checked), then I cannot select the locked cells (which is what I want).
If I save it, close it, then re-open it, I can once again select the locked cells. This is not what I want to happen.
Here is my code for opening and it is the same for closing, i.e. Workbook_BeforeClose(Cancel As Boolean)
What am I missing?
-Spydey
When I manually protect the worksheet, I cannot select the locked cells, which is what I am looking for. This is the correct behavior.
I have some code that runs when I open a workbook and when I close the workbook.
The code basically ensures that the worksheet is protected and only the options that I need available to the users are checked.
However, even though I have the EnableSelection:=xlUnlockedCells coded, it is not working.
When I open the file, it shows it is protected, yet I can select the locked cells, which I shouldn't be able to do.
If I then manually unprotect and then protect (all of the correct options are still checked), then I cannot select the locked cells (which is what I want).
If I save it, close it, then re-open it, I can once again select the locked cells. This is not what I want to happen.
Here is my code for opening and it is the same for closing, i.e. Workbook_BeforeClose(Cancel As Boolean)
VBA Code:
Private Sub Workbook_Open()
On Error Resume Next
With Worksheets("Tracker")
.Unprotect
.ShowAllData
.Protect , _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowSorting:=True, _
AllowFiltering:=True, _
AllowUsingPivotTables:=True, _
UserInterfaceOnly:=True
.EnableSelection = xlUnlockedCells
End With
On Error GoTo 0
End Sub
What am I missing?
-Spydey