Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default referencing a checkbox

I have been playing around with controls on excel 2007 and am getting
frustrated ofver something I am sure is very simple...I simply want to
perform an action when a checkbox = true. I have the following code:

Sub CheckBox1_Click()
If CheckBox1 = True Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If

End Sub

For some reason this code does not recognize when the checkbox is true or
not. can someone point me in the right direction?

Thanks!

Chad
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default referencing a checkbox

On 11 Jul., 00:11, Chad wrote:
I have been playing around with controls on excel 2007 and am getting
frustrated ofver something I am sure is very simple...I simply want to
perform an action when a checkbox = true. *I have the following code:

Sub CheckBox1_Click()
If CheckBox1 = True Then
* * ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If

End Sub

For some reason this code does not recognize when the checkbox is true or
not. *can someone point me in the right direction?

Thanks!

Chad


Hi

If CheckBox1.Value = True Then

Regards,
Per
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default referencing a checkbox

Is this a checkbox from the Control toolbox toolbar or is this a checkbox from
the Forms toolbar?

If it's from the control toolbox toolbar, then is your code under the worksheet
that holds that checkbox?

If it's from the Forms toolbar, then the code belongs in a General module and
needs to be modified.

Did you allow macros to run when you opened the workbook?

Chad wrote:

I have been playing around with controls on excel 2007 and am getting
frustrated ofver something I am sure is very simple...I simply want to
perform an action when a checkbox = true. I have the following code:

Sub CheckBox1_Click()
If CheckBox1 = True Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If

End Sub

For some reason this code does not recognize when the checkbox is true or
not. can someone point me in the right direction?

Thanks!

Chad


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default referencing a checkbox

I believe that the checkbox is from the forms toolbar (Is Office 2007 I go
under the Developer tab and then select 'Insert Control" and choose the
textbox under the form controls).

I have the code running under a module. The sub routine is called when the
checkbox is clicked, however, regardless of whether it is checked or not,
CheckBox1 is always recognized as False.

Thanks again for al lo fyour help.
Chad

"Dave Peterson" wrote:

Is this a checkbox from the Control toolbox toolbar or is this a checkbox from
the Forms toolbar?

If it's from the control toolbox toolbar, then is your code under the worksheet
that holds that checkbox?

If it's from the Forms toolbar, then the code belongs in a General module and
needs to be modified.

Did you allow macros to run when you opened the workbook?

Chad wrote:

I have been playing around with controls on excel 2007 and am getting
frustrated ofver something I am sure is very simple...I simply want to
perform an action when a checkbox = true. I have the following code:

Sub CheckBox1_Click()
If CheckBox1 = True Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If

End Sub

For some reason this code does not recognize when the checkbox is true or
not. can someone point me in the right direction?

Thanks!

Chad


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default referencing a checkbox

I was playing around a little bit more and I used the ActiveX controls to
insert a checkbox and it worked. Can someone tell me why inserting a
checkbox from the control toolbar doesn't work with this code?

Thanks!
Chad

"Chad" wrote:

I believe that the checkbox is from the forms toolbar (Is Office 2007 I go
under the Developer tab and then select 'Insert Control" and choose the
textbox under the form controls).

I have the code running under a module. The sub routine is called when the
checkbox is clicked, however, regardless of whether it is checked or not,
CheckBox1 is always recognized as False.

Thanks again for al lo fyour help.
Chad

"Dave Peterson" wrote:

Is this a checkbox from the Control toolbox toolbar or is this a checkbox from
the Forms toolbar?

If it's from the control toolbox toolbar, then is your code under the worksheet
that holds that checkbox?

If it's from the Forms toolbar, then the code belongs in a General module and
needs to be modified.

Did you allow macros to run when you opened the workbook?

Chad wrote:

I have been playing around with controls on excel 2007 and am getting
frustrated ofver something I am sure is very simple...I simply want to
perform an action when a checkbox = true. I have the following code:

Sub CheckBox1_Click()
If CheckBox1 = True Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If

End Sub

For some reason this code does not recognize when the checkbox is true or
not. can someone point me in the right direction?

Thanks!

Chad


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default referencing a checkbox

I have played around with the value property as well, but when I use that
code, I get an error saying that an object is required...

"Per Jessen" wrote:

On 11 Jul., 00:11, Chad wrote:
I have been playing around with controls on excel 2007 and am getting
frustrated ofver something I am sure is very simple...I simply want to
perform an action when a checkbox = true. I have the following code:

Sub CheckBox1_Click()
If CheckBox1 = True Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If

End Sub

For some reason this code does not recognize when the checkbox is true or
not. can someone point me in the right direction?

Thanks!

Chad


Hi

If CheckBox1.Value = True Then

Regards,
Per

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default referencing a checkbox

The activeX controls and the controls from the Control toolbox toolbar are
different terms for the same controls.

If you used the checkbox (not textbox) from the Forms toolbar, you could have
used:

Sub CheckBox1_Click()
If activesheet.checkboxes("CheckBox1").value = xlon Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If
End Sub



Chad wrote:

I was playing around a little bit more and I used the ActiveX controls to
insert a checkbox and it worked. Can someone tell me why inserting a
checkbox from the control toolbar doesn't work with this code?

Thanks!
Chad

"Chad" wrote:

I believe that the checkbox is from the forms toolbar (Is Office 2007 I go
under the Developer tab and then select 'Insert Control" and choose the
textbox under the form controls).

I have the code running under a module. The sub routine is called when the
checkbox is clicked, however, regardless of whether it is checked or not,
CheckBox1 is always recognized as False.

Thanks again for al lo fyour help.
Chad

"Dave Peterson" wrote:

Is this a checkbox from the Control toolbox toolbar or is this a checkbox from
the Forms toolbar?

If it's from the control toolbox toolbar, then is your code under the worksheet
that holds that checkbox?

If it's from the Forms toolbar, then the code belongs in a General module and
needs to be modified.

Did you allow macros to run when you opened the workbook?

Chad wrote:

I have been playing around with controls on excel 2007 and am getting
frustrated ofver something I am sure is very simple...I simply want to
perform an action when a checkbox = true. I have the following code:

Sub CheckBox1_Click()
If CheckBox1 = True Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If

End Sub

For some reason this code does not recognize when the checkbox is true or
not. can someone point me in the right direction?

Thanks!

Chad

--

Dave Peterson


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default referencing a checkbox

Thanks for the clarification Dave. I tried that and got an error saying:

'Unable to get the CheckBoxes property of the Worksheet class'

Any suggestions?

Again, I am using office 2007.

Thanks again!

Chad

"Dave Peterson" wrote:

The activeX controls and the controls from the Control toolbox toolbar are
different terms for the same controls.

If you used the checkbox (not textbox) from the Forms toolbar, you could have
used:

Sub CheckBox1_Click()
If activesheet.checkboxes("CheckBox1").value = xlon Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If
End Sub



Chad wrote:

I was playing around a little bit more and I used the ActiveX controls to
insert a checkbox and it worked. Can someone tell me why inserting a
checkbox from the control toolbar doesn't work with this code?

Thanks!
Chad

"Chad" wrote:

I believe that the checkbox is from the forms toolbar (Is Office 2007 I go
under the Developer tab and then select 'Insert Control" and choose the
textbox under the form controls).

I have the code running under a module. The sub routine is called when the
checkbox is clicked, however, regardless of whether it is checked or not,
CheckBox1 is always recognized as False.

Thanks again for al lo fyour help.
Chad

"Dave Peterson" wrote:

Is this a checkbox from the Control toolbox toolbar or is this a checkbox from
the Forms toolbar?

If it's from the control toolbox toolbar, then is your code under the worksheet
that holds that checkbox?

If it's from the Forms toolbar, then the code belongs in a General module and
needs to be modified.

Did you allow macros to run when you opened the workbook?

Chad wrote:

I have been playing around with controls on excel 2007 and am getting
frustrated ofver something I am sure is very simple...I simply want to
perform an action when a checkbox = true. I have the following code:

Sub CheckBox1_Click()
If CheckBox1 = True Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If

End Sub

For some reason this code does not recognize when the checkbox is true or
not. can someone point me in the right direction?

Thanks!

Chad

--

Dave Peterson


--

Dave Peterson

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default referencing a checkbox

Rightclick on the checkbox.
Look at the namebox (to the left of the formula bar)
You'll see its name.

If it's "Check Box 1", then you'd use:

ActiveSheet.CheckBoxes("Check Box 1").Value




Chad wrote:

Thanks for the clarification Dave. I tried that and got an error saying:

'Unable to get the CheckBoxes property of the Worksheet class'

Any suggestions?

Again, I am using office 2007.

Thanks again!

Chad

"Dave Peterson" wrote:

The activeX controls and the controls from the Control toolbox toolbar are
different terms for the same controls.

If you used the checkbox (not textbox) from the Forms toolbar, you could have
used:

Sub CheckBox1_Click()
If activesheet.checkboxes("CheckBox1").value = xlon Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If
End Sub



Chad wrote:

I was playing around a little bit more and I used the ActiveX controls to
insert a checkbox and it worked. Can someone tell me why inserting a
checkbox from the control toolbar doesn't work with this code?

Thanks!
Chad

"Chad" wrote:

I believe that the checkbox is from the forms toolbar (Is Office 2007 I go
under the Developer tab and then select 'Insert Control" and choose the
textbox under the form controls).

I have the code running under a module. The sub routine is called when the
checkbox is clicked, however, regardless of whether it is checked or not,
CheckBox1 is always recognized as False.

Thanks again for al lo fyour help.
Chad

"Dave Peterson" wrote:

Is this a checkbox from the Control toolbox toolbar or is this a checkbox from
the Forms toolbar?

If it's from the control toolbox toolbar, then is your code under the worksheet
that holds that checkbox?

If it's from the Forms toolbar, then the code belongs in a General module and
needs to be modified.

Did you allow macros to run when you opened the workbook?

Chad wrote:

I have been playing around with controls on excel 2007 and am getting
frustrated ofver something I am sure is very simple...I simply want to
perform an action when a checkbox = true. I have the following code:

Sub CheckBox1_Click()
If CheckBox1 = True Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If

End Sub

For some reason this code does not recognize when the checkbox is true or
not. can someone point me in the right direction?

Thanks!

Chad

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default referencing a checkbox

Perfect!

Thanks for all of yoru help.

Chad

"Dave Peterson" wrote:

Rightclick on the checkbox.
Look at the namebox (to the left of the formula bar)
You'll see its name.

If it's "Check Box 1", then you'd use:

ActiveSheet.CheckBoxes("Check Box 1").Value




Chad wrote:

Thanks for the clarification Dave. I tried that and got an error saying:

'Unable to get the CheckBoxes property of the Worksheet class'

Any suggestions?

Again, I am using office 2007.

Thanks again!

Chad

"Dave Peterson" wrote:

The activeX controls and the controls from the Control toolbox toolbar are
different terms for the same controls.

If you used the checkbox (not textbox) from the Forms toolbar, you could have
used:

Sub CheckBox1_Click()
If activesheet.checkboxes("CheckBox1").value = xlon Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If
End Sub



Chad wrote:

I was playing around a little bit more and I used the ActiveX controls to
insert a checkbox and it worked. Can someone tell me why inserting a
checkbox from the control toolbar doesn't work with this code?

Thanks!
Chad

"Chad" wrote:

I believe that the checkbox is from the forms toolbar (Is Office 2007 I go
under the Developer tab and then select 'Insert Control" and choose the
textbox under the form controls).

I have the code running under a module. The sub routine is called when the
checkbox is clicked, however, regardless of whether it is checked or not,
CheckBox1 is always recognized as False.

Thanks again for al lo fyour help.
Chad

"Dave Peterson" wrote:

Is this a checkbox from the Control toolbox toolbar or is this a checkbox from
the Forms toolbar?

If it's from the control toolbox toolbar, then is your code under the worksheet
that holds that checkbox?

If it's from the Forms toolbar, then the code belongs in a General module and
needs to be modified.

Did you allow macros to run when you opened the workbook?

Chad wrote:

I have been playing around with controls on excel 2007 and am getting
frustrated ofver something I am sure is very simple...I simply want to
perform an action when a checkbox = true. I have the following code:

Sub CheckBox1_Click()
If CheckBox1 = True Then
ThisWorkbook.Sheets("Sheet1").Cells(1, 1) = "A"
End If

End Sub

For some reason this code does not recognize when the checkbox is true or
not. can someone point me in the right direction?

Thanks!

Chad

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing Checkbox Names Chad Excel Worksheet Functions 1 July 18th 08 11:28 PM
link a checkbox in a sheet to a checkbox on a userform? Arjan Excel Programming 0 November 10th 06 01:37 PM
How do I link one checkbox to update another checkbox? Mike Excel Programming 3 April 28th 06 02:22 AM
checkbox on form reset from checkbox on sheet raw[_12_] Excel Programming 1 December 3rd 05 05:08 AM
referencing a checkbox cell address in a worksheet Erik Andreassen[_2_] Excel Programming 1 June 28th 05 02:30 PM


All times are GMT +1. The time now is 02:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"