ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protecting a worksheet (https://www.excelbanter.com/excel-programming/414190-protecting-worksheet.html)

Anthony

Protecting a worksheet
 
Hi all

I have a worksheet that contains aprox 8 buttons that each run a macro to
complete certain tasks from displaying userforms to moving to another
worksheet.

Rather than adding code into each macro, is there a way to protect the
worksheet, unprotect whilst any macro is run then protect it again once the
macro is complete?

thanks

Jim Thomlinson

Protecting a worksheet
 
You will have to add code to each button but you can make the code very short
by addin two procedures to do the protection and unprotection. Call the
unprotectall macro at the start and the protectall at the end of each command
button procedure...

sub UnProtectAll
dim wks as worksheet

for each wks in thisworkbook.worksheets
wks.unprotect Password:="Tada"
next wks
End sub

sub ProtectAll
dim wks as worksheet

for each wks in thisworkbook.worksheets
wks.protect Password:="Tada"
next wks
End sub

--
HTH...

Jim Thomlinson


"Anthony" wrote:

Hi all

I have a worksheet that contains aprox 8 buttons that each run a macro to
complete certain tasks from displaying userforms to moving to another
worksheet.

Rather than adding code into each macro, is there a way to protect the
worksheet, unprotect whilst any macro is run then protect it again once the
macro is complete?

thanks


macgru

Protecting a worksheet
 
try to find Protect Method/ UserInterfaceOnly in help
mcg


Użytkownik "Anthony" napisał w
wiadomości ...
Hi all

I have a worksheet that contains aprox 8 buttons that each run a macro to
complete certain tasks from displaying userforms to moving to another
worksheet.

Rather than adding code into each macro, is there a way to protect the
worksheet, unprotect whilst any macro is run then protect it again once
the
macro is complete?

thanks





All times are GMT +1. The time now is 01:00 PM.

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