I get the catch-all runtime error 1004, "unable to set the Locked property of the Range class" when, well, trying to set the Locked
property of a Range object. The code looks like this:
that_goddamn_sheet.Unprotect
; Determine if we should proceed
that_goddamn_range.Locked = True
; Do more stuff
that_goddamn_sheet.Protect
When I set a breakpoint on the line and try to query the value of that_goddamn_range.Locked
from the Immediate window, this works without problem, but setting it fails.
If, however, I run that_goddamn_range.Select
, break the macro, unprotect the sheet (it gets reprotected automatically on selection change) then right click, pick Properties, switch to the Protection tab and tick Locked then confirm, things work okay however.
What could possibly be going wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…