View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
nospaminlich nospaminlich is offline
external usenet poster
 
Posts: 68
Default Protect/Unprotect Not Working

I have a sheet with lots of Option Buttons and a few input cells.

The sheet is protected and each macro starts ActiveSheet.Unprotect and
finishes ActiveSheet.Protect

This is the start of the macro for Option Button 10

ActiveSheet.Unprotect
OptionButton4.Value = True (To reset to the default button in another
group)
Application.ScreenUpdating = False
Range("J4").Select
ActiveCell.FormulaR1C1 = "2"

For some reason it keeps falling over at the last line above with a run-time
error 1004 message saying the cell or chart I'm trying to change is protected
and therefore read only.

This doesn't seem to happen every time the macro runs but quite frequently.

I don't understand how this can happen given the first line in the macro
unprotects the sheet.

I'm confused. Is there a better way to write this that would be more robust?

Thanks a lot