Deactivate option button and cell

Ravi321

New Member
Joined
Jul 9, 2013
Messages
5
Hi friends,

What I need to do is,
- If fruits is selected in question 1,
then automatically OptionButton3, OptionButton4 & OptionButton5 should get activated
and OptionButton6, OptionButton7 and cell E9 should get deactivated (means user should be restricted to use them).
- if vegetables is selected in qusetion1 ,
then automatically OptionButton6, OptionButton7 and cell E9 should get activated
and OptionButton3, OptionButton4 & OptionButton5 should get deactivated

I have used activeX option buttons as that is the requirement from my boss.
I tried to use If-Then-Else but its not working
frown.gif
.

Sample workbook
https://www.dropbox.com/s/j36csnsj3gcfbbq/Option button deactivation.xlsm

<input id="ext_msg_elm" type="hidden">
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
If you go into Design Mode (Developer tab and click on the Ruler, Pencil and Set Square icon) then double-click one of your checkboxes it will take you to the macro editing screen. You will automatically be given the first and last line of a macro which you must not change. In between those two lines you can add vba commands. You need to change the Enabled property of the checkboxes to False to disable them and true to enable them. For instance:

Code:
Private Sub OptionButton1_Click()
    OptionButton2.Enabled = False
    MsgBox "OptionButton1_Click() False"
End Sub

The above code will prevent changes being made to OptionButton2.

I suspect that you will also need a WorksheetOpen event to make the correct initial settings for these checkboxes because if a checkbox is not actually clicked then the actions will not be performed and everything will start enabled.

You can find out which properties are available by right-clicking a checkbox and selecting properties.

I hope this helps.
 
Upvote 0
For starters Group OptionButton1 and OptionButton2 so that only one of them may be selected. This can be set from the control properties. Then in the Sheet Code module:

Code:
Private Sub OptionButton1_Click()
testValues
End Sub

Private Sub OptionButton2_Click()
testValues
End Sub

Sub testValues()
If OptionButton1.Value Then
    OptionButton3.Enabled = True
    OptionButton4.Enabled = True
    OptionButton5.Enabled = True
    OptionButton6.Enabled = False
    OptionButton7.Enabled = False
Else
    OptionButton3.Enabled = False
    OptionButton4.Enabled = False
    OptionButton5.Enabled = False
    OptionButton6.Enabled = True
    OptionButton7.Enabled = True
End If
End Sub
 
Upvote 0
Thanks a lot Teeroy and RickXL for your reply, it helped me a a lot :) <input id="ext_msg_elm" type="hidden">
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top