Preventing Movement in Protected Areas in Microsoft Excel

A

andremations

Hi All,

Is there a way to save the EnableSelection property of a sheet? Because
whenever I open a saved sheet after I have changed the EnableSelection
property from 0-x|NoRestrictions to 1-x|UnlockedCells the property
always changes back 0-x|NoRestrictions. Thanks in advance.

Andre
 
D

Dave Peterson

You could set it each time the workbook opens (with macros enabled):

Option Explicit
Sub auto_open()
Dim wks As Worksheet
Set wks = Worksheets("sheet1")
With wks
.Select
.Protect
.EnableSelection = xlUnlockedCells
End With
End Sub
 
A

andremations

Thanks for the quick reply Dave!

I have already placed the "script" that you told me in VBA. Got one
more question here... (I am really new to most advanced features of
Excel). Can you please tell me how to Enable the Macros?
 
D

Dave Peterson

Two steps.

Depending on your version, the options could be different--but in xl2002+
Tools|macro|security|security level
change your setting to medium to be prompted each time you open a workbook with
macros or change it to low to never be prompted. (Low isn't recommended by MS.)

Then close your workbook and reopen it.
Answer yes to allow macros (if you get prompted).

Note that this is a user setting. If you share the workbook with others,
they'll have to make the same kind of decisions. You won't be able to change
this setting (via your code) if they don't enable macros.
 
Top