+ Reply to Thread
Results 1 to 8 of 8

I would like to run VBA code when a check box is checked.

  1. #1
    Forum Contributor
    Join Date
    05-02-2013
    Location
    Indiana
    MS-Off Ver
    Microsoft 365 (Subscription)
    Posts
    192

    I would like to run VBA code when a check box is checked.

    Hello,

    I have five check boxes, when the first one is checked I would like to check the rest of the boxes (Checkbox 2 - Checkbox 5). And also in reverse, when I uncheck the first one I would like to uncheck boxes 2 - 5. I have written the code, but it does not work. Can someone, tell me what I am doing wrong!!

    Thanks
    redsab
    Attached Files Attached Files
    Last edited by redsab; 09-01-2013 at 06:59 PM.

  2. #2
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: I would like to run VBA code when a check box is checked.

    Basically for this purpose, you won't require any VBA codes, you'll have to link the controls to a common cell. Attached is your file with screenshots on how to do that.
    Attached Files Attached Files
    cOdEsLiZeR - Back after a long break.. Let's sLiZe some more cOdEs!!

  3. #3
    Forum Contributor
    Join Date
    05-02-2013
    Location
    Indiana
    MS-Off Ver
    Microsoft 365 (Subscription)
    Posts
    192

    Re: I would like to run VBA code when a check box is checked.

    codeslizer,

    That works great, and was very simple. However, when I protect the spread sheet it does not allow me to check the box. Well it allows me to check one box at a time. Would there be any kind of a work-around that you can see?

    Thanks,
    redsab

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: I would like to run VBA code when a check box is checked.

    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  5. #5
    Forum Contributor
    Join Date
    05-02-2013
    Location
    Indiana
    MS-Off Ver
    Microsoft 365 (Subscription)
    Posts
    192

    Re: I would like to run VBA code when a check box is checked.

    Solus,
    That did work, but how did you get those check boxes highlited? What's the secreate? This is not my real worksheet, it is just a test worksheet I was working on for an example. It really astounds me the amount of brilliants that is at this forum. I have never post a question, that someone could not solve. Thanks Solus!

    redsab

  6. #6
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: I would like to run VBA code when a check box is checked.

    Those checkboxes are activex checkboxes instead of the standard form controls. If you right click them and select properties you can get an idea of all they can do. IMHO they are much more versatile while being easier to use.

    Also they have events which standard form controls do not. (I used the click event to call the macro)

  7. #7
    Forum Contributor
    Join Date
    05-02-2013
    Location
    Indiana
    MS-Off Ver
    Microsoft 365 (Subscription)
    Posts
    192

    Re: I would like to run VBA code when a check box is checked.

    Solus,
    I have been working with your example and modified it at bit and changed the senario. I would like to have Checkbox3 be the one you click on to automatically check box3 - box10. But I do not want it to check box1 or box2. I have programed box1 and box2 to display a message when they are checked. I am not sure how to exclude boxes 1 & 2. At the moment, if I check box3 it checks all of my boxes 1 - 10. I am new to VBA and I have not worked with Active X Controls. Would you mind to show me how to modify CheckBox3_Click() to accomplish this senario! Thanks in advance!!

    redsab
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    05-02-2013
    Location
    Indiana
    MS-Off Ver
    Microsoft 365 (Subscription)
    Posts
    192

    Re: I would like to run VBA code when a check box is checked.

    Solus,
    Nevermind, I came up with a solution.

    Please Login or Register  to view this content.
    Thanks for your help, I could not have done it without your help!

    redsab
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Automatically check one or more check boxes when a parent check box is manually checked
    By Steverizer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-28-2013, 01:56 PM
  2. Replies: 2
    Last Post: 12-19-2012, 11:23 PM
  3. [SOLVED] I need a pop up message when a check box is checked
    By Kipp in forum Excel General
    Replies: 1
    Last Post: 10-20-2005, 06:50 PM
  4. Print when check box checked
    By vincenealon in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-26-2005, 08:41 AM
  5. Disableing a check box when another is checked
    By Rich Kniatt in forum Excel General
    Replies: 2
    Last Post: 01-28-2005, 10:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1