Protecting a worksheet

jfish1288

Board Regular
Joined
Jun 22, 2011
Messages
116
I am using the code below to protect a worksheet, allowing the user to only be able to edit a few cells. I also would like the user to only be able to select the unlocked cells. The code below acomplishes that, but when I save reopen the file it now allows the user to select any cell. The sheet is still protected from edits but I would like the user to be prevented from selecting other cells also. Any idea what I am doing wrong?

Code:
With ComparisonWB.Worksheets("Intro")
    .Activate
    .Unprotect Password:="MLGW"
    .Range("H5:P5,H7:P7,H9:P9,H11,H12,H14,H15,H16,H18, N11").Select
    Selection.Locked = False
    Selection.FormulaHidden = False
    .Protect Password:="MLGW", DrawingObjects:=True, Contents:=True, Scenarios:=True, UserInterfaceOnly:=True
    .EnableSelection = xlUnlockedCells
End With
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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