+ Reply to Thread
Results 1 to 18 of 18

Toggle multiple checkboxes (only one checkbox is allowed at a time)

  1. #1
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Hi,
    I try to take few checkbox, I can toggle each box but only one checkbox is allowed liked the option button.
    I like to keep the linked cells to TRUE or FALSE.

    I am not sure I have posted this before.

    Thanks
    Last edited by Rocky2013; 04-13-2015 at 10:38 PM.

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    You can put this into a Standard Module and assign each checkbox to this macro

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Hello,
    Mike it works except I forgot to mention, there are other check boxes for whose does not need to be
    allow one check mark but multiple check marks (stand form buttons). Also there may be another
    group of check boxes will do the same only allow one check mark in my form.

    My guest if this is possible to group them or specifified checkbox names that only allow one check mark.

    In the attachment, I add a group 2 of check boxes which allow multiple check marks. When I click any checkbox
    in group 1, check marks in group 2 get "uncheck"; which suppose not to affect.


    Thanks
    Last edited by Rocky2013; 04-11-2015 at 08:15 AM.

  4. #4
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Please Login or Register  to view this content.
    Please click the * below if this helps

  5. #5
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Hi JasperD,
    the code is not working. For example: If any checkbox in box5 to box7 is not checked (false),
    When I click any check box 1 to 4 (even box has a check mark (true)) will add check marks to
    all check marks to box 5, 6, 7.

    Basicly I can check and uncheck box 5, 6, and 7, box 1-4 do not get changes.
    But not the other way.

    Please advise.
    Last edited by Rocky2013; 04-11-2015 at 02:51 PM.

  6. #6
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    You're right, sorry.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Hello,
    it works except one little problem I found hopefully it is not an issue.
    One one of checkbox 1 to 4 is checked. I cannot uncheck the same one
    turn in a FALSE. Because the form is start with all checkboxes are unchecked.
    If I precheck the box it could cause problem.

    I like to see the same box in group 1 can be checked and unchecked liked the regular
    checkbox.

    Thanks

  8. #8
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Hi,
    Finally I got what I want, it is working perfectly.
    Thanks for your time and effort.

    Also thanks to Mike.

    Best Regards,

  10. #10
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Another way

    Please Login or Register  to view this content.
    Last edited by mike7952; 04-13-2015 at 02:07 PM.

  11. #11
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Mike,
    Thanks. This is also a nice way to group the box1 to box 4 use as option button.
    Most checkboxes in my form are the normal form buttons except 1 or 2 places
    using option buttons (a checkbox style instead of round).

    But how to uncheck the checkbox that has a check mark in Group 1? Basicly I like to click again
    to uncheck.


    Thanks for another tip.

    Regards,
    Last edited by Rocky2013; 04-13-2015 at 09:05 AM.

  12. #12
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Hello JasperD,
    I notice that if there is a text box (which is also a shape", when I click any box1 to 4. A pop-up "Run-time error '438': Object doesn't this property
    or method" will show. If I delete the text box then there will be pop-up.

    My real form has pop-up text box or pop-up comments.


    Hello Mike,
    I have same issue with your code on pop-up 438 error.


    Please advise.
    Last edited by Rocky2013; 04-13-2015 at 01:28 PM.

  13. #13
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    I have updated the code to uncheck check box if check box is already check in post #10

  14. #14
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Hi Rocky,

    originally I just adjusted Mike's code, so it's logical they give the same error.
    The 'problem' lies in that other shapes don't necessarily have the possibility to be 'true' or 'false'

    Please Login or Register  to view this content.
    The line in bold is added and basically checks for the word 'check' in the name (check box).
    This should fix your problem.

  15. #15
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Hello JasperD,
    Now it works I can check and uncheck checkbox in group 1, also no error pop-up error anymore.


    Hello Mike,
    JasperD use your orginal code and solve the problem.

    "Mike, sorry for keep coming back. Can you please take a look at the attached that the code is from your 13.
    The attached codes suppose to do uncheck the boxes in group 1. The reason I want to revisit your code, when I try to add
    to the form, all my ~30 checkboxes are standard form control except 1 group is acted like a option checkbox.
    I am looking for your help. "


    Special thanks to both of you, and the team work that provding the help and solution.

    Best Regards!
    Last edited by Rocky2013; 04-13-2015 at 09:12 PM.

  16. #16
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Hell Mike,
    After few try and error, it seems it work now.
    This is what I did
    1. Delete "Exit for"
    2. Move up ".ControlFormat.Value = xlOn" above End If"

    PHP Code: 
    Sub cbChecked()
     
    ReDim ckboxGroup1(1 To 4)
     
    ckboxGroup1 = [{"Check Box 1","Check Box 2","Check Box 3","Check Box 4"}]
     
     For 
    1 To 4
        With ActiveSheet
    .Shapes(ckboxGroup1(i))
            If 
    Application.Caller = .Name Then
                
    if .ControlFormat.Value xlOn then
                   
    .ControlFormat.Value xloff
                
    .ControlFormat.Value xlOn  
                End 
    if
                        Else
                .
    ControlFormat.Value xlOff
            End 
    If
        
    End With
     Next
     
    End Sub 
    Last edited by Rocky2013; 04-13-2015 at 10:34 PM.

  17. #17
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    This should do it

    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Toggle multiple checkboxes (only one checkbox is allowed at a time)

    Mike,
    Your final code did it!

    When I played around your code, even the vba syntax in post 16 does not look right but it works.
    I will use yours.

    Thanks
    Last edited by Rocky2013; 04-14-2015 at 06:23 AM.

+ 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. Select All Checkboxes Checkbox That Also Calls Checkbox Macros
    By Intervigilium in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2015, 06:41 PM
  2. One checkbox that selects multiple checkboxes
    By pozmoney in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2013, 05:57 PM
  3. Replies: 2
    Last Post: 10-19-2011, 09:45 AM
  4. Multiple checkboxes to tick 1 checkbox
    By tUyET dEn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2009, 04:07 AM
  5. I only want one checkbox to be allowed at a time
    By Adeptus - ExcelForums.com in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-09-2005, 02:05 PM

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