Error locking cell

G

Guest

Hi,

I receive the following error when trying to lock a cell via a macro -
"Unable to set the Locked Property of the Range class.". My code basically
writes a value into an unlocked cell, unprotects the sheet, changes the cell
to locked, then re-protects the sheet. Code is below:

Range("O73").Select
ActiveCell.FormulaR1C1 = "CHECKED"
ActiveSheet.Unprotect Password:="ABC"
Selection.Locked = True
ActiveSheet.Protect Password:="ABC"

The error occurs at "Selection.Locked" stage. Can anyone help me?????

Thanks,
Richard.
 
G

Guest

Richard,

I've just tried your code in a command button and it worked ok, no probs.
Where are you running the code from?
 
G

Guest

I'm running the code from an excel add-in. The sheet seems to protect and
unprotect fine, but it just fails to lock the cell.
 
G

Guest

Only a suggestion? Only the answer to the problem I've been having all
morning! Thanks very much.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top