ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   When using an Option Button can I... (https://www.excelbanter.com/excel-programming/306129-when-using-option-button-can-i.html)

phil[_2_]

When using an Option Button can I...
 
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

Jim Rech

When using an Option Button can I...
 
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
"phil" wrote in message
...
| 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



No Name

When using an Option Button can I...
 
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

-----Original Message-----
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
"phil" wrote in message
...
| 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


.


Jim Rech

When using an Option Button can I...
 
You're close. Check out the Protect method in Help for the exact syntax.
--
Jim Rech
Excel MVP

wrote in message
...
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

-----Original Message-----
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
"phil" wrote in message
...
| 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


.





All times are GMT +1. The time now is 10:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com