protection and macros

  • Thread starter Thread starter Sam
  • Start date Start date
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!
 
Add a couple of lines to your macro:

worksheets("sheet1").unprotect password:="hi"
'your sort code
worksheets("sheet1").protect password:="hi"
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top