ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   locking tabs w/macros (https://www.excelbanter.com/excel-discussion-misc-queries/34024-locking-tabs-w-macros.html)

erik

locking tabs w/macros
 
i have a workbook that employees use to track project progress. they enter
project data into sheet 1 and vbscript macros manipulate this data and output
it in various ways on worksheets 2-15. i want to lock sheets 2-15 so
employees cannot enter data, but when i protect those sheets the macros are
no longer permitted to work. is there a way i can prevent cell editing by
USERS but permit editing by MACROS? this seems like it should be fairly
obvious, but i cant figure it out. thanks in advance!

KL

Hi eric,

1) you might want to use the following instruction when protecting the
sheets:

ActiveSheet.Protect Password:="Password", UserInterfaceOnly:=True

this line has to be executed every time you open the file as the
UserInterfaceOnly parameter is not saved, so you may want to build it into
the Workbook_Open event.

2) another option is to include into your code instructions that would
unprotect and then protect your sheets, e.g:

ActiveSheet.Unprotect "Password"
'.....your code
ActiveSheet.Protect "Password"

Regards,
KL


"erik" wrote in message
...
i have a workbook that employees use to track project progress. they enter
project data into sheet 1 and vbscript macros manipulate this data and
output
it in various ways on worksheets 2-15. i want to lock sheets 2-15 so
employees cannot enter data, but when i protect those sheets the macros
are
no longer permitted to work. is there a way i can prevent cell editing by
USERS but permit editing by MACROS? this seems like it should be fairly
obvious, but i cant figure it out. thanks in advance!




erik


KL, thanks so much - your option #2 worked perfectly!


"KL" wrote:

Hi eric,

1) you might want to use the following instruction when protecting the
sheets:

ActiveSheet.Protect Password:="Password", UserInterfaceOnly:=True

this line has to be executed every time you open the file as the
UserInterfaceOnly parameter is not saved, so you may want to build it into
the Workbook_Open event.

2) another option is to include into your code instructions that would
unprotect and then protect your sheets, e.g:

ActiveSheet.Unprotect "Password"
'.....your code
ActiveSheet.Protect "Password"

Regards,
KL


"erik" wrote in message
...
i have a workbook that employees use to track project progress. they enter
project data into sheet 1 and vbscript macros manipulate this data and
output
it in various ways on worksheets 2-15. i want to lock sheets 2-15 so
employees cannot enter data, but when i protect those sheets the macros
are
no longer permitted to work. is there a way i can prevent cell editing by
USERS but permit editing by MACROS? this seems like it should be fairly
obvious, but i cant figure it out. thanks in advance!






All times are GMT +1. The time now is 08:33 AM.

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