vba to permanently disable checkbox( greyed)

aman2059

Board Regular
Joined
Jan 17, 2016
Messages
75
Hi All,

I have created one user form with checkboxes and command button.

Could anyone please suggest how can I permanently disable the checkbox so that no one can click on the box.

I used below code

Code:
Private Sub CheckBox1_Click()
CheckBox1.Value = False
End Sub

It make the check box unclickable but it doesn't grey the checkbox. Please suggest how can I grey the check box, so that user look on the checkbox and understand that there is nothing with this checkbox.

Thank you
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi Andrew,

I used below

Code:
Private Sub CheckBox1_Click()
CheckBox1.Value = False
CheckBox1.Enabled = False
end sub

it greys the box when I CLICK on it. However, before clicking on it, the box looks like I can click on it. I want whenever I run the vba. it shows grey checkbox since the beginning.

Please help
 
Upvote 0
You can set the Enabled property at design time in the Properties window. Or you can use the UserForms's Initialize event procedure.
 
Upvote 0
Got your point. I changed enabled property from properties window. thank you

My last question - I have few check boxes in user form which depend on prior box. like - if someone clicks on 1st box then only another box should be clickable. I have below code which is working fine.

Code:
Private Sub CheckBox10_Click()
Select Case CheckBox1.Value
    Case True: CheckBox10.Enabled = True
    Case False: CheckBox10.Enabled = False: CheckBox10.Value = False
End Select
End Sub

However, in this code also when I click on the particular box then only it becomes grey . And it is not greyed from the beginning.

What I want is when I click on 1st button then only other should become clickable. until then another box should be grey.

Do I need to use UserForms's Initialize event procedure? If yes, could you please help I am not sure how use event procedure.
 
Upvote 0
If you want the CheckBox to be enabled when the UserForm is loaded:

Code:
Private Sub UserForm_Initialize()
    CheckBox10.Enabled = False
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,645
Messages
6,120,711
Members
448,984
Latest member
foxpro

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