running a macro on a protected sheet

  • Thread starter Thread starter kriss
  • Start date Start date
K

kriss

I've got a scenario where I've got several option buttons
in groups to make choices. I've got the sheet protected
so the buttons and/or groups can't be accidentally moved
by the user. However, I've created a "clear all" button
so the user can reset the form to redo their option button
choices, if they need to. But, when protected, the macro
attached to the "clear all" button won't work (due to the
protection). How do I get around this? Thanks!
 
Kriss, here is one way
Sub test1()
ActiveSheet.Unprotect password:="123"
'you clear code here
ActiveSheet.Protect password:="123"
End Sub

--
Paul B
Always backup your data before trying something new
Using Excel 97 & 2000
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **
 
Paul -

Thank you - I think this will work, however I am a bit
Visual Basic Challenged! I keep getting a "Compile
Error". Any advice?
 
Kriss, To put in this macro, from your workbook right-click the workbook's
icon and pick View Code. This icon is to the left of the "File" menu this
will open the VBA editor, in the left hand window click on your workbook
name, go to insert, module, and paste the code in the window that opens on
the right hand side, press Alt and Q to close this window and go back to
your workbook and press alt and F8, this will bring up a box to pick the
Macro from, click on the Macro name to run it. If you are using excel 2000
or newer you may have to change the macro security settings to get the macro
to run.
This has the password set as 123, put your code where it says your code
here and assign the macro to your button, or if its a command button put it
in the code for that button.

--
Paul B
Always backup your data before trying something new
Using Excel 97 & 2000
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **
 
PAUL!!

By George, I've got it! I really can't thank you
enough!! You're a lifesaver!
kriss
 
Back
Top