PDA

View Full Version : Solved: Testing the value of a check box



austenr
11-02-2005, 07:18 AM
This seems simple enough but I cannot figure this out. Can someone please tell me what is causin an "Invalid Qualifier" error on the first line of the if statement?

The check box is on a sheet and it came from the forms toolbar. Thanks

Sub CheckBoxCheck()
Dim CheckBox1 As Long
If CheckBox1.Value = 1 Then
Range("A5").Value = 1
End If
End Sub

Bob Phillips
11-02-2005, 07:33 AM
This seems simple enough but I cannot figure this out. Can someone please tell me what is causin an "Invalid Qualifier" error on the first line of the if statement?

The check box is on a sheet and it came from the forms toolbar. Thanks

Sub CheckBoxCheck()
Dim CheckBox1 As Long
If CheckBox1.Value = 1 Then
Range("A5").Value = 1
End If
End Sub

You have Dimmed Checkbox1 as a long, and try and test that value property, a Long doesn't have a Value property.

The correct way to test a checkbox is

If ActiveSheet.CheckBoxes("Check Box 1").Value = 1 Then
range("A5").Value = 1
End If

But why not just link the checkbox to cell A5, and let Excel do it.

BTW, didn't you also post this on OzGrid?

austenr
11-02-2005, 07:39 AM
Hi x,

Yes I did and I tried to close the thread but could not find a way to close it. I am aware of how the cross post is rude. I am going to go to Ozgrid and see if I can close it. Thanks for the help.

austenr
11-02-2005, 07:45 AM
Do the names of the check boxes always have to be Check Box 1, Check Box 2, etc?

Bob Phillips
11-02-2005, 09:17 AM
Do the names of the check boxes always have to be Check Box 1, Check Box 2, etc?

No, you can change them. Select the change box, and the name then pops up in the Names box, left of the formula bar. Just5 change it there.

Ken Puls
11-02-2005, 10:28 AM
Hi x,

Yes I did and I tried to close the thread but could not find a way to close it. I am aware of how the cross post is rude. I am going to go to Ozgrid and see if I can close it. Thanks for the help.

Hi Austen,

I wouldn't sweat it too much, but if you are going to cross post, please do post a link pointing to the other post. (Both ways, preferably). This lets your potential responders all work on the same premises and they know when to stop as well. ;)