• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

7. Macro Hacks > 93. Run Procedures on Protected Worksheets

Run Procedures on Protected Worksheets

Excel macros are a great way to save time and eliminate errors. However, sooner or later you might try to run your favorite Excel macro on a worksheet that has been protected, with or without a password, resulting in a runtime error. Avoid that problem with the following hack.

If you have ever tried to run an Excel macro on a worksheet that’s been protected, you know that as soon as the worksheet is encountered, your macro probably won’t work and instead will display a runtime error.

One way to get around this is to use some code such as the following to unprotect and then protect your worksheet:

Sub MyMacro( )

Sheet1.Unprotect Password:="Secret"

'YOUR CODE

Sheet1.Protect Password:="Secret"
End Sub

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint