protection and macros

S

Sam

I need to protect a worksheet, but users need to be able
to click a button that runs a macro (which sorts the
protected information). How can I protect it, while
still allowing the macro button to work? Thanks!
 
D

Dave Peterson

Add a couple of lines to your macro:

worksheets("sheet1").unprotect password:="hi"
'your sort code
worksheets("sheet1").protect password:="hi"
 
S

Sébastien

Hi Sam,
You need your code to:
1.Unprotect the sheet
.Unprotect(Password)
2. Run the button process
3. Re-protect the sheet
.Protect Password, DrawingObjects, Contents, Scenarios, UserInterfaceOnly

Regards,
Sébastien
 
S

Sébastien

Hi Sam,

You need your code to:
1.Unprotect the sheet using the worksheet method:
.Unprotect(Password)
2. Run the button process code
3. Re-protect the sheet using the sheet method
.Protect Password, DrawingObjects, Contents, Scenarios, UserInterfaceOnly

Regards,
Sébastien
 
Top