Cell restriction removed when reopening.

Ste_Moore01

Active Member
Joined
Jul 13, 2005
Messages
467
I've got a spreadsheet that I protect with a password, and I restrict access to the unlocked cells.

When I saved my spreadsheet everything was fine but when I reopened it I could select all the cells even though they were still locked.

Can anyone solve this for me?

Thanks!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Ste_Moore01

If you have Excel 2002(?) or later, when you protect the sheet, there are choices about whether the user can select locked and/or unlocked cells. This property may help you. If you have an earlier version of Excel you have more of a problem (VBA solution).

However, search this board because I am sure there is a recent thread on the same (or similar) topic.
 
Upvote 0
I have locked the cells I don't wish to be accessed and I've saved the file after I protected the sheets with only unlocked cells accessable.

The problem is when I reopen it I can select all the cells.

I use a macro to lock the sheet.

This is the code
Code:
Sub Protect()
    Windows("pw.xls").Visible = True
    Sheets("PasswordSheet").Select
    Dim Password As Range
    Set Password = Range("B1")
    ActiveWindow.Visible = False
    ActiveSheet.Protect Password
    ActiveSheet.EnableSelection = xlUnlockedCells
End Sub

The code works perfectly but I save the file and reopen it and all cells can be selected.

I saw the post you were referring to before but it didn't metion something on these lines.
 
Upvote 0
need help too

I'm having the same problem, specially when opening the project disabling macros (protection remains, but the formulas are visible).

My project is getting big (4 usrforms, macros on opening and closing, etc.).

So, I've tried with a new file, empty, some cells unblocked (data entry cells), and this code:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

With Worksheets(1)
    .Protect Password:="ggg", Contents:=True, UserInterFaceOnly:=True
    .EnableSelection = xlUnlockedCells
End With
    ActiveWorkbook.Save

End Sub

Private Sub Workbook_Open()

Dim wSheet As Worksheet


 With Worksheets(1)
    .Protect Password:="ggg", Contents:=True, UserInterFaceOnly:=True
    .EnableSelection = xlUnlockedCells
End With

End Sub

This solution worked fine only after opening, unprotecting, setting the property xl..., protecting again, saving and closing. It seems that the information is recorded within the file. When reopening, it keeps the cells protected. (yes!)

But when i was applying this to my big project, it has rejected. 8(

(i believe that there is too much code, and now i have to check all, and i'm a little tired of it).

Hope it helps. Any sugestion?
best regards
 
Upvote 0

Forum statistics

Threads
1,202,987
Messages
6,052,932
Members
444,616
Latest member
novit19089

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top