![]() |
How can you create a macro on a protected sheet?
I have a shared worksheet that I have password protected so no one can change
formulas in the cells. I would like to set up macros to provide me with a certain view for printing and research. Everytime I set up the macro and protect the sheet it says that I can not use the macro. Is there anyway around this or will I have to unprotect the sheet everytime I want to use the macro? Any ideas or suggestions would be greatly appreciated. Thank you. |
How can you create a macro on a protected sheet?
You could have the macro unprotect the sheet, run what it is suppose to do and then have it re-protect it. -- patrickcairns ------------------------------------------------------------------------ patrickcairns's Profile: http://www.excelforum.com/member.php...o&userid=31790 View this thread: http://www.excelforum.com/showthread...hreadid=515557 |
How can you create a macro on a protected sheet?
If you set up the protection and the macro, then you know the password?
Option Explicit sub testme() dim myPWD as string myPwd = "hi there" activesheet.unprotect password:=myPWD 'do your stuff activesheet.protect password:=mypwd end sub ====== Depending on what your code does, you could even protect it in code (each time the workbook opens) and tell excel that you want to allow your macro to do things that the humans can't. Option Explicit Sub auto_open() With Worksheets("Sheet 99") .Protect Password:="hi there", userinterfaceonly:=True End With End Sub It needs to be reset each time you open the workbook. (excel doesn't remember it after closing the workbook.) But there are a few things that can't be done by your macro--you'll want to test it to see if it works with the stuff you do. Felix wrote: I have a shared worksheet that I have password protected so no one can change formulas in the cells. I would like to set up macros to provide me with a certain view for printing and research. Everytime I set up the macro and protect the sheet it says that I can not use the macro. Is there anyway around this or will I have to unprotect the sheet everytime I want to use the macro? Any ideas or suggestions would be greatly appreciated. Thank you. -- Dave Peterson |
All times are GMT +1. The time now is 12:31 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com