blaksnm
Well-known Member
- Joined
- Dec 15, 2009
- Messages
- 554
- Office Version
- 365
- Platform
- Windows
Hey Guys
I have made two OptionButtons to activate 2 different macros - both used in a protected sheet.
The macros unprotect the current sheet , do stuff and then protect it again.
Running macro1 works all right on 1st move.
However, when I run macro2 (by activating OptionButton2) after running macro1 (activated by OptionButton1) the macro will not unprotect the sheet as expected, and abend the macro.
The same result when reversing the actions.
The funny part is that when the procedure is done/macros are run by run directly in VBA - it seems to work well...!
I've obiously have missed something on the road here - but what?
Here is an extract of my macros:
Sub ActivateOptionButton1()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
' Do stuff
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Application.ScreenUpdating = True
End Sub
Sub ActivateOptionButton2()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
' Do stuff
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Application.ScreenUpdating = True
End Sub
I have made two OptionButtons to activate 2 different macros - both used in a protected sheet.
The macros unprotect the current sheet , do stuff and then protect it again.
Running macro1 works all right on 1st move.
However, when I run macro2 (by activating OptionButton2) after running macro1 (activated by OptionButton1) the macro will not unprotect the sheet as expected, and abend the macro.
The same result when reversing the actions.
The funny part is that when the procedure is done/macros are run by run directly in VBA - it seems to work well...!
I've obiously have missed something on the road here - but what?
Here is an extract of my macros:
Sub ActivateOptionButton1()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
' Do stuff
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Application.ScreenUpdating = True
End Sub
Sub ActivateOptionButton2()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
' Do stuff
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Application.ScreenUpdating = True
End Sub