ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macros with Protected Worksheets (https://www.excelbanter.com/excel-discussion-misc-queries/83088-macros-protected-worksheets.html)

Terri

Macros with Protected Worksheets
 
Hi,

Can you run a macro when you have the worksheet protected? If so, how do I
get this to work in Excel?
--
Terri

Paul B

Macros with Protected Worksheets
 
Terri, one way is to unprotect the sheet run your code and then protect the
sheet all with your code, like this

Sub My_Macro()

Const PW As String = "123" 'Change Password Here

ActiveSheet.Unprotect Password:=PW

'you code here

ActiveSheet.Protect Password:=PW

End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"Terri" wrote in message
...
Hi,

Can you run a macro when you have the worksheet protected? If so, how do
I
get this to work in Excel?
--
Terri





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

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