Stopping a Checked Box from being Unchecked

Written by Allen Wyatt (last updated July 30, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


Noel created a form that includes some check boxes. When someone selects the check box (so that a check appears in it), he would like to "lock" it so that the check box cannot then be unchecked.

This is very easy to do if you are using ActiveX check boxes in your form. All you need to do is remember that when the check box is clicked, an event is triggered for that checkbox. Let's say that your checkbox has a default name, such as CheckBox1. In this case, the CheckBox1_Click() event is triggered. Within the event handler, you can do just about anything you desire, including making sure that the check box stays checked.

Private Sub CheckBox1_Click()
    MsgBox "ActiveX CheckBox1 Clicked"
    If CheckBox1.Value = False Then CheckBox1.Value = True
End Sub

This approach works because the Value property of the check box is toggled whenever the check box is clicked. If it toggles to False (which means it is no longer checked), then you can immediately set the Value property back to True (meaning it is checked). This could be simplified a bit in this manner:

Private Sub CheckBox1_Click()
    MsgBox "ActiveX CheckBox1 Clicked"
    If Not (CheckBox1) Then CheckBox1 = 1
End Sub

In fact, you could simplify it even further in this way:

Private Sub CheckBox1_Click()
    MsgBox "ActiveX CheckBox1 Clicked"
    CheckBox1 = True
End Sub

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13415) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Changing the Way Endnotes Are Numbered

Word is flexible on how it numbers your endnotes. This tip shows how easy it is to make the changes to the numbering system.

Discover More

Copying the Results of Filtering

Filtering is a great asset when you need to get a handle on a subset of your data. Excel even makes it easy to copy the ...

Discover More

Renaming and Deleting Icons

Want to change the name of a desktop icon or get rid of it entirely? It's easier to do than you probably think!

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Trimming Spaces from Strings

Need to get rid of extraneous spaces before or after the text in a string? VBA provides three different functions you can ...

Discover More

Copying Worksheet Code Automatically

When creating a workbook to be used by others, you may want any worksheets they add to the workbook to contain some ...

Discover More

Page Numbers in VBA

When you print a larger worksheet, Excel breaks the printout across several pages. You may want to know, before you ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one less than 9?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.