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
- 22377 reads
Recent comments
5 years 34 weeks ago
6 years 20 weeks ago
6 years 32 weeks ago
6 years 35 weeks ago
6 years 36 weeks ago
6 years 42 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago