Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Only run if check box is checked

I have some code that I only want to be run if a check box is checked. So I
inserted an ActiveX check box which I have named cbRecord.

I then put the following IF around the code which is initiated by clicking a
spinner form control:

If cbRecord.Value Then
....
....
....
End If

However, when the code is run I get the following error: Run time error
'424': Object required. When I go to debug, the code doesn't even know that
my check box exists.

TIA...Geoff

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Only run if check box is checked

Try

If Sheets("Sheet1").CheckBoxes("Check Box 1").Value = xlOn Then
'do stuff
End If
--
Cheers,
Ryan


"Geoff" wrote:

I have some code that I only want to be run if a check box is checked. So I
inserted an ActiveX check box which I have named cbRecord.

I then put the following IF around the code which is initiated by clicking a
spinner form control:

If cbRecord.Value Then
...
...
...
End If

However, when the code is run I get the following error: Run time error
'424': Object required. When I go to debug, the code doesn't even know that
my check box exists.

TIA...Geoff

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Only run if check box is checked

or even tighter (since we know the name of the ActiveX checkbox):

If Sheets("Sheet1").cbRecord then
'do stuff
End if

"Ryan H" wrote:

Try

If Sheets("Sheet1").CheckBoxes("Check Box 1").Value = xlOn Then
'do stuff
End If
--
Cheers,
Ryan


"Geoff" wrote:

I have some code that I only want to be run if a check box is checked. So I
inserted an ActiveX check box which I have named cbRecord.

I then put the following IF around the code which is initiated by clicking a
spinner form control:

If cbRecord.Value Then
...
...
...
End If

However, when the code is run I get the following error: Run time error
'424': Object required. When I go to debug, the code doesn't even know that
my check box exists.

TIA...Geoff

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Only run if check box is checked

Many thanks. That worked. I don't know what I was doing wrong. I basically
copied the code from another spreadsheet I made a ways back. And it still
works there. VBA in Excel is still pretty mysterious to me and not nearly as
easy as Access for me.

"B Lynn B" wrote:

or even tighter (since we know the name of the ActiveX checkbox):

If Sheets("Sheet1").cbRecord then
'do stuff
End if

"Ryan H" wrote:

Try

If Sheets("Sheet1").CheckBoxes("Check Box 1").Value = xlOn Then
'do stuff
End If
--
Cheers,
Ryan


"Geoff" wrote:

I have some code that I only want to be run if a check box is checked. So I
inserted an ActiveX check box which I have named cbRecord.

I then put the following IF around the code which is initiated by clicking a
spinner form control:

If cbRecord.Value Then
...
...
...
End If

However, when the code is run I get the following error: Run time error
'424': Object required. When I go to debug, the code doesn't even know that
my check box exists.

TIA...Geoff

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Only run if check box is checked

I think I figured it out. The code was in a generic module and not in the
module for the specific worksheet.

"Geoff" wrote:

Many thanks. That worked. I don't know what I was doing wrong. I basically
copied the code from another spreadsheet I made a ways back. And it still
works there. VBA in Excel is still pretty mysterious to me and not nearly as
easy as Access for me.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Only run if check box is checked

Thanks Ryan. Now I get: Run time error '1004': Unable to get the Checkboxes
property of the Worksheet class.

There's nothing in the Locals window.

"Ryan H" wrote:

Try

If Sheets("Sheet1").CheckBoxes("Check Box 1").Value = xlOn Then
'do stuff
End If


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
all the check boxes should be checked if i check a particular checkbox in that row [email protected] Excel Programming 3 April 18th 07 09:20 AM
I need a pop up message when a check box is checked Kipp Excel Discussion (Misc queries) 1 October 20th 05 11:50 PM
Check box so that only one box can be checked a time Norm Hamilton Excel Discussion (Misc queries) 1 August 22nd 05 09:26 AM
How do I get a Check Box to set a value in a cell when is checked. aaarbelo Excel Programming 1 March 26th 05 05:55 PM
Check box - checked or unchecked? Greg Billinge Excel Programming 2 August 19th 04 10:05 AM


All times are GMT +1. The time now is 09:57 AM.

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

About Us

"It's about Microsoft Excel"