When using an Option Button can I...

P

phil

Lock a particular cell?

I have optYes and optNo. When optYes is selected I would
like the contents of cell M42 on worksheet WS2 to have a
"locked" state, whereas no data can be entered. And when
optNo is selected I would like the contents to be fully
editable. Is there such a work-around for this?

Thanks in advance for your help.

Phil Diederich
 
J

Jim Rech

I assume the option buttons are on a worksheet and they're from the Forms
toolbar...

You can right-click each button, pick Assign Macro to name a macro to be run
when each option button is clicked. The code could be:

Sub OptionButton1_Click()
Range("M42").Locked = True
End Sub

Sub OptionButton2_Click()
Range("M42").Locked = False
End Sub

If the sheet is protected you will have to unprotect/re-protect it before
and after.

--
Jim Rech
Excel MVP
| Lock a particular cell?
|
| I have optYes and optNo. When optYes is selected I would
| like the contents of cell M42 on worksheet WS2 to have a
| "locked" state, whereas no data can be entered. And when
| optNo is selected I would like the contents to be fully
| editable. Is there such a work-around for this?
|
| Thanks in advance for your help.
|
| Phil Diederich
 
G

Guest

Yes they are from the Forms toolbar. Is there any code
that would automatically unprotect and protect the
worksheet? I am working with a few numbskulls who aren't
proficient with a PC. Would the following work?

Sub optYes_Click()
Worksheets("WS2").Protect.Password := "xxxxx"
End Sub
 

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