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
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

aman2059

Board Regular
Joined
Jan 17, 2016
Messages
75
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
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
You can set the Enabled property at design time in the Properties window. Or you can use the UserForms's Initialize event procedure.
 

aman2059

Board Regular
Joined
Jan 17, 2016
Messages
75

ADVERTISEMENT

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.
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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:

Watch MrExcel Video

Forum statistics

Threads
1,122,842
Messages
5,598,394
Members
414,234
Latest member
grlevesq

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
Top