ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro doesn't work when I use Protection (https://www.excelbanter.com/excel-programming/335096-macro-doesnt-work-when-i-use-protection.html)

Janet H.

Macro doesn't work when I use Protection
 
I have a macro to insert rows in my worksheet. When I turn on protection, so
user can only access unlocked cells, my macro will not work. How can I use
both the macro and the protection option?

ben

Macro doesn't work when I use Protection
 
unprotect your worksheet before you do your code and then protect when done
ie...
you can remove the password key word if there is no password
ie
activesheet.unprotect


sub insertrows()
activesheet.unprotect password:="enter your password here"
'insert rows edit cells whatever here
activesheet.protect password:="enter your password here"
end sub


--
When you lose your mind, you free your life.


"Janet H." wrote:

I have a macro to insert rows in my worksheet. When I turn on protection, so
user can only access unlocked cells, my macro will not work. How can I use
both the macro and the protection option?


Curt

Macro doesn't work when I use Protection
 
Is there a way to have a password on a sheet or workbook and have VBA still
unlock and protect with same password after. At present I try and get box to
enter password.
Any ideas Thanks a lot
Curt

"ben" wrote:

unprotect your worksheet before you do your code and then protect when done
ie...
you can remove the password key word if there is no password
ie
activesheet.unprotect


sub insertrows()
activesheet.unprotect password:="enter your password here"
'insert rows edit cells whatever here
activesheet.protect password:="enter your password here"
end sub


--
When you lose your mind, you free your life.


"Janet H." wrote:

I have a macro to insert rows in my worksheet. When I turn on protection, so
user can only access unlocked cells, my macro will not work. How can I use
both the macro and the protection option?



All times are GMT +1. The time now is 07:48 PM.

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