ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   protection and macros (https://www.excelbanter.com/excel-programming/301922-protection-macros.html)

Sam

protection and macros
 
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!

Dave Peterson[_3_]

protection and macros
 
Add a couple of lines to your macro:

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

Sam wrote:

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!


--

Dave Peterson


Sébastien

protection and macros
 
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ébastien[_2_]

protection and macros
 
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


All times are GMT +1. The time now is 06:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com