MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Checkbox


Posted by Kim on August 09, 2001 3:33 PM

I'm trying to get the following to work:

I built a form with checkboxes (yes/no per question) and I need it to do the following: if the checkbox 4 is checked, I want it to automatically check checkbox 13.

I wrote a simple subscript with if then (because I'm a beginner) but it doesn't seem to work. Can someone help me out?


Posted by steve w on August 09, 2001 4:37 PM

Can I see some code that you wrote
also what do you want to happen and do you have an OK button on the form and do you want it to run after the OK button is pushed.

If you have an OK button then somethink like this

commandbutton1_click()
If checkbox4.value = true then
if checkbox13.value =true then
"Your code here"
End if
End if
unload userform1
end sub

Posted by Kim on August 09, 2001 4:49 PM

Keep in mind that I almost have no idea what I'm doing .. all I know is from what I heard people say so please, don't all laugh at the same time!

Here is the code I had that didn't work:

Private Sub CheckBox4_Click(A4 As CheckBox)
If CheckBox4.Value = True Then
CheckBox13.Value = True
End If
End Sub

To answer your question, I do not have an OK button on the form. I just want the users to avoid contradictions by answering 2 questions that exclude each other. Actually, it would be amazing if instead of checking box13, it grayed it out so they wouldn't be allowed to use it ...

Thanks for the help!

Posted by steve w on August 09, 2001 5:11 PM

Its ok you have to start learning sometime, it gets easier with time.
What do you mean by A4 as checkbox?
How do you want checkbox 13 to gray out, is it going to do it by some other checkbox?
To gray out a checkbox how about using this
checkbox13.disabled= true

try this code
steve w

Private Sub CheckBox4_Click()

If CheckBox4.Value = True Then
CheckBox13.Value = True
CheckBox13.Enabled = False
Else
CheckBox13.Enabled = True
CheckBox13.Value = False
End If

End Sub

Posted by Kim on August 10, 2001 5:20 PM

Thanks! It worked!