+ Reply to Thread
Results 1 to 13 of 13

VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

  1. #1
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    Hi all. Can anyone please assist me with a code on how to uncheck 2 checkboxes if 1 checkbox in same row is ticked.
    I have 3 checkboxes in every row. Currently, I have a code but it's not stable to do the job. I originally have checkbox from form control but code doesn't work, so I changed it to activeX control yet more than 2 boxes are found to have tick mark.

    I use checkbox to state the status of an equipment either Available & in good condition, Not available, and Faulty. With these status, it cannot happen that 2 boxes are checked at the same time.

    Please help! It will really be appreciated. Thanks in advance!-hydz1213

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    11-02-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    564

    Re: VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    Why not use Option Buttons instead of Checkbox?
    Upload your workbook with Form control and activex controls so that we can check where it is causing errors.

  3. #3
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    Quote Originally Posted by haripopuri View Post
    Why not use Option Buttons instead of Checkbox?
    Upload your workbook with Form control and activex controls so that we can check where it is causing errors.
    Hello haripopuri

    I didn't think of option buttons. will it work if there will be 3 option buttons in each row to code?
    Anyway, I have attached a sample sheet of what i'm doing. The first row has 3 activeX control that somehow worked with the code i have. Next row has 3 form controls but i don't have code to work with it.

    Just to add I have about 200+ more command buttons in the original file that i'm working on and each row has 3 command buttons.

    Thank you so much for your time. I really hope we can sort this out.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    Quote Originally Posted by haripopuri View Post
    Why not use Option Buttons instead of Checkbox?
    Upload your workbook with Form control and activex controls so that we can check where it is causing errors.
    haripopuri, i tried inserting 6 option buttons in my worksheet. but it seems like regardless how many option buttons i have, i can only choose one. but each row is different equipment already and that i must have an option to choose which status for that equipment. i tried changing the sequence# of the other 3 (option4,5,6 to option5,6,7) to maybe break the chain and allow me to choose another option button for 2nd row but it's still linking to the other first 3 option buttons.

    is there a way i can have option buttons in each row and be able to choose one button in every row without affecting the others?

    thanks for your time again

  5. #5
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    Hi,

    Attached is your solution.

    The tick marks are a result of conditional formatting. Have a look at that in case your range exceeds the range already defined by me.

    Hope this helps.
    Attached Files Attached Files
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  6. #6
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    Quote Originally Posted by xlbiznes View Post
    Hi,

    Attached is your solution.

    The tick marks are a result of conditional formatting. Have a look at that in case your range exceeds the range already defined by me.

    Hope this helps.
    Thank you so much Xlbiznes! I will check your attachment now

  7. #7
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    Quote Originally Posted by xlbiznes View Post
    Attached is your solution.

    Hope this helps.
    Thank you very much Xlbiznes! Your code works perfectly to what I need!

  8. #8
    Valued Forum Contributor
    Join Date
    11-02-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    564

    Re: VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    You will have to group your radio buttons and make sure GroupName in Properties of the buttons are different for different set of buttons you would like to select independently.

  9. #9
    Forum Guru mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,207

    Re: VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    My Mac doesn't support ActiveX controls, but if .GroupName is a property of an ActiveX option button, you might run code like

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  10. #10
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    Thank you guys for your time and suggestions. I'll try the GroupName property some time later in some of my projects. But for now, I think I'm perfectly fine with the conditional formatting.

    Thanks again. Cheers!
    -hydz1213

  11. #11
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    Hi hydz1213,

    If you are satisfied with the solution offered, please mark this thread as solved.

  12. #12
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    Quote Originally Posted by xlbiznes View Post
    Hi hydz1213,

    If you are satisfied with the solution offered, please mark this thread as solved.
    Hi Xlbiznes,

    I marked this earlier as Solved after I received your file. In my screen it's already showing [SOLVED]. I used the thread tools at the top of the page, unless it's not the way to mark this post. In case, please let me know how.

    Thanks again for your solution!

  13. #13
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked

    Hi Hydz1213,

    Oops, I missed that. It is marked as solved now.

    Glad, that my solution has helped you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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