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

0
Utf
1/26/2010 9:56:19 PM
excel.programming 6508 articles. 2 followers. Follow

5 Replies
5236 Views

Similar Articles

[PageSpeed] 9

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
> 
0
Utf
1/26/2010 10:19:01 PM
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
> > 
0
Utf
1/26/2010 10:33:01 PM
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

0
Utf
1/26/2010 10:33:02 PM
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
> > > 
0
Utf
1/26/2010 11:25:01 PM
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.

0
Utf
1/27/2010 12:18:01 AM
Reply:

Similar Artilces:

Keeping focus on a text box
I have a form on which I'm using my own record selector buttons to move between records. I'd like to use some code to keep focus on a particular text box (ItemNum) when moving between records if ItemNum had the focus prior to moving to the next record. ItemNum is not the default 1st Text box on the form. Any suggestions? Thanks Kevin D "Kevin D." <KevinD@discussions.microsoft.com> wrote in message news:BF2CEF17-ADA7-4253-8CDD-DB2AC3DD5117@microsoft.com... > I have a form on which I'm using my own record selector buttons to move > between records. I...

combo box look
the combo boxes on my form makes my fom look bad. I have changed the back and border color of the combo boxes to match the background of my form. However, the dropdown arrows stick out like a sore thumb and ruins the appearance of my form. This maybe a high expectation, but is there a way to change the looks of the combo boxes. For example can you get rid of the dropdown arrow? -- Message posted via http://www.accessmonster.com ...

Make text boxes the same height
I have 3 seperate text boxes that are side by side on a report, they vary in height and can grow, I want to put a solid box around each but I want them all to default to the tallest so as they look uniform when printed. I have spent a long time looking at other posts and trying some OnPrint event procedures but with no luck so far. I hope someone can help, thanks in advance Open your report in Design View and right click on your textbox and open the properties. Under the Format tab you will see a Width and Height field. These are the fields to adjust your textbox. If you hold down the ...

Starting a dialog box minimized
I would like my dialog-based application to start up with the dialog box minimized. One of the properties of the main window in a window-based application is to start minimized but that property isn't present for the dialog box. I've looked through the various messages but the only ones I see are ones that are sent to the window when it gets minimized - none to tell it to minimize. Ive tried placing "PostMessage(WM_SIZE, SIZE_MINIMIZED, 0);" in my "xxx::OnInitDialog()" function but that doesn't do it. How should this be done? Thanks, Ray Mitchell ...

Checking Data Change on Close
I want a data editing form to check for any changes when an exit button is clicked. So here is the following code that I have done. (I always get Run Time Error 13. Type Mismatch) Any help would be greatly appreciated! Private Sub Form_Close() If Me.DataChange Then Dim strMsg As String Dim Cancel As Integer strMsg = "Data has changed." strMsg = strMsg & " Do you wish to save the changes?" strMsg = strMsg & " Click Yes to Save or No to Discard changes." If MsgBox(strMsg, vbQuestion + vbYesNo, &...

Run my App from Function Key
Is there a way to program a windows function like F1 so that when I press it, windows launches my custom application? On Mar 7, 6:56=A0pm, Joe Cool <joecool1...@live.com> wrote: > Is there a way to program a windows function like F1 so that when I > press it, windows launches my custom application? Let me add, without having to download/buy another app to do it? How would I perform this function myself? On 08/03/2010 01:15, Joe Cool wrote: > On Mar 7, 6:56 pm, Joe Cool<joecool1...@live.com> wrote: >> Is there a way to program a windows function like F1 ...

VBA Event Procedures won't run in Access 2007
For some strange reason none of my Event Procedures are running in my access database. I can use macros for events just fine, but if I want to use a VBA event procedure nothing happens. If I put breakpoints in at any event in the VBA code, I never see a single one come up. What is going on here? Do I have to enable VBA somewhere in Access 2007? I'm really pulling my hair out with this one. Thanks for any help! -mindseye11 See this page for a nice explanation: http://www.access.qbuilt.com/html/trust_center.html -- Jeff Conrad - Access Junkie - MVP Alumni SDET - XAS Services - Microsoft...

How do I remove a combo box in Excel 2007
I have excel 2003 at work and I inserted a combo box (I think that is what it is called) with a drop down menu. I am at home now using a computer with Excel 2007 and I want to remove this Combo Box, but I can't find the tool bar (control box?) that I used to create/edit it. This is quite frustrating. Can anyone tell me where it is please? I want to remove this box. You have to show the developer's tab on the ribbon. That's under the office button|excel options. It's a checkbox in the top section of the Popular category. Then look in the Developer's group on the ribbon. ...

Run macro on selected sheets
Hi I have a workbook with 103 sheets, I want a macro to run on 100 of the sheets. Here is the macro, can anyone help me with this? Sub ReconsileStockCard() Range("D3").Select ActiveCell.FormulaR1C1 = "=SUM(R[4]C[-2]:R[97]C[-2])" Range("D3").Copy Range("B7").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Range("A7:A36,B8:B36").ClearContents Range("D3").ClearContents Range("D7").ClearContents...

Macro should not Run when Excel Sheet is Protected
Some of the defined Macros should not work when a Sheet is Protected and only the specific Users should have access Hi you could check in the macro if the sheet is protected. e.g. directly from the VBA help: If Worksheets("Sheet1").ProtectContents = True Then MsgBox "The contents of Sheet1 are protected." End If -- Regards Frank Kabel Frankfurt, Germany "Chakradhar" <Chakradhar@discussions.microsoft.com> schrieb im Newsbeitrag news:D0E7AA7C-1690-4DE5-B0BD-DF4C09413BEC@microsoft.com... > Some of the defined Macros should not work when a Sheet is ...

account reconciliation does not show total deposits/checks
hi, this must have been answered before, but i couldn't find it, so here goes. i've got Money 2004, and now Money 2006 (trial version). all i want to do is balance a checking account with my bank statement, and i am used to seeing the total deposits and totals deductions as part of the process. even the Money help file says it should be in the left pane, but...it is not! and it is not present in either version. i couldn't find any settings to change for this. so, this looks like is a major flaw, can anyone help? i don't reallky want to switch to Quicken... thanks, ...

Getting rid of confirmation boxes
Hello, Is there a way to get rid of confirmation boxes popping up in Excel? I use Excel 2000 on WinNT4 and I need to keep a spreadsheet open 24/7 doing calculations. The problem is the sheet runs 50+ external database queries to an sql server set to refresh every minute and occasionally a "Not enough memory to complete query" error or similiar pops up with an "OK" button to click. The entire spreadsheet stops running any queries while this "OK" button waits for someone to click it! Its very annoying. Especially when I check it after a week and its had a mes...

email does not appear in the "in box" it just does not appear at all
Outlook 2003 XP All was working well until I switched to AT&T U-Verse (my mistake). The change to their new POP3 mail servers has caused the following condition: Junk mail is received and displayed in the "junk e-mail" folder. Regular email does not appear at all, yet it can be found received on the web mail browser. Their tech support seems to be at a loss and started finger pointing. Any help here will be much appreciated. Do you have any rules enabled that could be moving things around? Are you receiving any errors when the send/receive process completes? &q...

Checking if a cell is filled up with data
Hi! I would like to write a function that checks if a cell is empty or if it has any kind of data. The kind of datas (numbers or words or bocth) is irrelevant. The only thing that is important is whether or not the cell is empty. Has anyone an idea how I could write such a function? Thanks -- xpucto ------------------------------------------------------------------------ xpucto's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=23748 View this thread: http://www.excelforum.com/showthread.php?threadid=374119 =IF(A1="","",A1) Enter this f...

IMF running?
Exchange 2003 SP2 on Windows 2003 SP1 Server. I've enabled Intelligent Messaging Filter on the Default SMTP Virtual Server Properties. I've pretty much left the Intelligent Message Filtering tab on Global Settings, Message Delivery alone for the time being. I've restarted the SMTP server and IIS (for good measure). I've also applied the IMF patch that I found at Microsoft Update. Nothing seems to be happening though :/ I've fired up performance monitor and added all the IMF counters in, switched to report view and there's nothing against any of them (we get 1...

Checks posted to GL - status as 'work'
I posted a check batch and it posted through to the GL, however, when I do an inquiry on the vendor - the payment shows as 'work', there is no check number associated with it, and the invoice it paid still shows up on my AP. I can't find a fix for this on Partner Source's Knowledge Base. Any help is greatly appreciated. Upon further inspection - they did not post through to the GL. The check batch printed and all the payments are in work status but I can't find the batch anywhere to fully post it. -- Cornerstone Enterprise Soltuions, LLC. Chicago, IL ...

Publisher 98 running in Windows XP Pro
I loaded Publisher 98 on my new computer with Windows XP Pro. However, I cannot open files created in Publisher 98 on a Windows 98 machine. Is there a way to open these files? Do you have Norton? Disable "script blocking", still in Norton, options, clear "Office Plug-ins" -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.mvps.org/msauer/ news://msnews.microsoft.com "Carla" <anonymous@discussions.microsoft.com> wrote in message news:1b3ee01c44fc7$cb82a700$a501280a@phx.gbl... > I loaded Publisher 98 on my new computer with Windows XP > P...

mutli-select list box problem
The following code is my failed attempt to get the items picked in a multi-select List box to then appear in another form named "NameDetailForm". The NameDetailForm does open but does not show the items picked from the list box. I believe the end part of my code is flawed, but cannot figure out what it should correctly be. If there is better code for this purpose, I would appreciate seeing it. Private Sub Itemschosen_Click() Dim strWhere As String, varItem As Variant If Me!NameListBox.ItemsSelected.Count = 0 Then Exit Sub For Each varItem In Me!NameListBox.ItemsSelec...

Message box blocking PostMessage() API
Hi, i am trying to show a message box when i try to quit from my application.I already have 1 thread running in background which does some specific operation.if i wont respond to the message box, i am using PostMessage() to a window which is in another dll.PostMessage() is not doing the job. I could not see the message i have posted using Spy++ resulting in odd behavior of the PostMessage(). Is there anything like 'not responding to a messagebox() will block PostMessage() call' or is it the problem of threads. In my case message is being sent from UI thread of my application to ...

Pausing between edit box writes
I'm writing a VC++ 6.0 app. where I output messages on a text box using the CDialog class's DoDataExchange method. I do the following.... CString m_Display; m_Display = "First Display"; DoDataExchange(...) ::Sleep(4000); m_Display = "Second Display"; DoDataExchange(...); I expect to see "First Display", pause for 4secs, then "Second Display". However, I don't see the "First Display" at all - I just see a blank, and then "Second Display". What gives? What's another technique to do this? -Zilla There is...

Check Numbers in 2006 Deluxe
Money 2006 is not pulling in the check number when I download transactions from my bank. I know the check numbers are in the file because if I open the file with notepad I see the check numbers. This makes it a little more diffiuclt to reconcile my entries with the banks entries. Any help in resolving this issue is greatly appreciated. Thanks, Jason "Jason" <Jason@discussions.microsoft.com> wrote in message news:BE0E1BF9-50FC-4952-B9A3-03D08FFC22C0@microsoft.com... > Money 2006 is not pulling in the check number when I download transactions > from my bank. I know ...

tristate check box #2
I have a tristate check box.The default behavour of tristate check box in windows is that, the grayed check box will become unchecked after click on grayed check box. But i want , the grayed check box will become checked after click on grayed check box in VC++ .Pls help me its urgent. Well, for Win32, you can always SendMessage the button a BM_GETSTATE. I'm sure with MFC there's a function that will permit this; it could be as simple as button_name.GetState(). Well, for the event OnClick for that button, you can get the state of the button and then either run it through some if-...

External program/file/task opening/running from Outlook Calendar
Hello: Suppose I create a "New Appointment" in Outlook Calendar (and set an appointment reminder as well). What I would like to do is automatically run/open some program/file (say, an existing PDF document) come the (reminder) time. Is there any way this sort of automation can be enabled in Outlook? Thank you in advance for any tips or suggestions. ...

IE opens with "about:blank" url when I run my solution
Ever since I installed IE8 it opens with "about:blank" url when I run my solution. I close that instance and another instance opens that runs OK. I figured when that first happened that MS would soon fix it but to my knowledge they haven't. Is that correct or am I missing something or doing something wrong? Thank ...

FW: Check out the important pack
--lpduusan Content-Type: multipart/related; boundary="oofqhgqqli"; type="multipart/alternative" --oofqhgqqli Content-Type: multipart/alternative; boundary="rudixxccz" --rudixxccz Content-Type: text/plain Content-Transfer-Encoding: quoted-printable MS Customer this is the latest version of security update, the "December 2008, Cumulative Patch" update which fixes all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express. Install now to protect your computer. This update includes the functionality = of all pre...