CheckBox is checked or not
CheckBoxes are very common in Excel forms. Based on the condition whether it is checked or not, you may want to run some code.
Now, how would you check whether the CheckBox is checked or not? It is very simple, use the steps below.
Steps:
1. Open a new file
2. Press Alt+F11 to open VBA editor
3. In the left navigation value select ThisWorkbook
4. In the editor window enter the code below
5. Close the VBA editor
6. Save the file as Macro Enabled File
7. Test with you inputs
Code:
Sub CheckBox()
Dim CheckBox As Shape
Set CheckBox = ActiveSheet.Shapes("Check Box 1") 'Change the CheckBox number you want to check
If CheckBox.OLEFormat.Object.Value = 1 Then
MsgBox "Checkbox is Checked" 'Add your code here which you want to run when CheckBox is checked
Else
MsgBox "Checkbox is not Checked" 'Add your code here which you want to run when CheckBox is not checked
End If
End Sub
CheckBox is Checked
CheckBox is Not Checked
I think this has been informative and I thank you for viewing.
-Saurabh
Attachment | Size |
---|---|
CheckingCheckBox.xlsm | 13.86 KB |
- saurabhlakhanpal's blog
- Login or register to post comments
- 22385 reads
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago