Hi -- I'm working on some VBA in Excel 2000 to automate some spreadsheet tasks. I have a really basic question about checkboxes... I've been using a "toy" program to try to figure out how to get the program to tell which box is checked. The form is created under forms in the VBA IDE (not in the sheet itself)
Whenever I run this I get count = 1 no matter what is checked
I have also tried approaches "viewing the code" by right clicking on the control and attempting similar code (except using CheckBox1.Value instead.
If the CheckBox1_Click () is the only way to do it, how can I reference the responses in another macro (like with a global variable, perhaps?)
Apologies for the noob question, but I have searched around for a basic explanation of Checkboxes with a "Hello World" type example and found none.
Code:
Sub Macro1()
Dim count As Integer
count = 0
MyForm.Show
If MyForm.CheckBox1.Value Then
count = count + 1
End If
If MyForm.CheckBox2.Value = 1 Then
count = count + 1
End If
If MyForm.CheckBox3.Value = vbChecked Then
count = count + 1
End If
MsgBox (count)
End Sub
I have also tried approaches "viewing the code" by right clicking on the control and attempting similar code (except using CheckBox1.Value instead.
If the CheckBox1_Click () is the only way to do it, how can I reference the responses in another macro (like with a global variable, perhaps?)
Apologies for the noob question, but I have searched around for a basic explanation of Checkboxes with a "Hello World" type example and found none.
Comment