+ Reply to Thread
Results 1 to 19 of 19

UserForm if checkbox is checked then check the others and viceversa

  1. #1
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    UserForm if checkbox is checked then check the others and viceversa

    Hello everyone!

    I'm new to Excel Userforms and VBA, and I need a little help.
    I have a Userform with 4 Checkboxes, named from Checkbox 1 thru Ckeckbox 4, and I want to do the following:

    -If Checkbox 1 is true, then all the other checkboxes are true
    -If Checkbox 1 is false, then all the other checkboxes are false (these were the easier )
    -If one or two of the Checkboxes 2,3,4 is selected, then I want that Checkbox 1 became "Null"
    -If all the three Checkboxes (2,3,4) are checked, then I want Checkbox 1 to be automatically became true. Is this posible?

    My code looks like this:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,192

    Re: UserForm if checkbox is checked then check the others and viceversa

    When you say "Null" do you mean a value of zero...If so one has to set the triplestate property to Yes
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,192

    Re: UserForm if checkbox is checked then check the others and viceversa

    Hi bgabi89

    Is this what you require
    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: UserForm if checkbox is checked then check the others and viceversa

    Use OptionButton instead.

  5. #5
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: UserForm if checkbox is checked then check the others and viceversa

    I'm not familiar with option buttons, I can put more than one option?

  6. #6
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: UserForm if checkbox is checked then check the others and viceversa

    @sintek: The first part of the code I made with If statements because I have separate name for each checkbox. The case where Checkbox1 will be selected if the other three are selected I want to resolve without the need to press a buton, automaitcally, just like in the first case

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,192

    Re: UserForm if checkbox is checked then check the others and viceversa

    This is the only way I know to do part 2
    Please Login or Register  to view this content.
    End Sub

  8. #8
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: UserForm if checkbox is checked then check the others and viceversa

    Yes, but with this method CheckBox1 will be selected even if only one of the Checkboxes is selected, but I want to be selected only when all the three of them are selected. Anyway, thanks for help

  9. #9
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: UserForm if checkbox is checked then check the others and viceversa

    I would like to use this code, but I don't know why isn't working:

    Please Login or Register  to view this content.
    What can I change in this code to make working?

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,192

    Re: UserForm if checkbox is checked then check the others and viceversa

    You are trying to check the variables of Checkboxes 2 , 3 & 4 in CheckBox1_Change Event
    Not possible I'm sure....That's why I put it in a command Button

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: UserForm if checkbox is checked then check the others and viceversa

    Hi bgabi89,

    Is this what you want?

    Please Login or Register  to view this content.
    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: UserForm if checkbox is checked then check the others and viceversa

    1) Add a Class module and name it as EventControl and paste following code.
    Please Login or Register  to view this content.
    2) UserForm code (name user form as UserForm1)
    Please Login or Register  to view this content.
    3) To a standard module (add one if you haven't got any)
    to a general declaration area
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: UserForm if checkbox is checked then check the others and viceversa

    Hi Winom,

    No, I don't want this, anyway, thanks for the idea

  14. #14
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: UserForm if checkbox is checked then check the others and viceversa

    @ jindon

    I made all the steps you mentioned, but nothing happens when I select Checkboxes 2,3 and 4

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: UserForm if checkbox is checked then check the others and viceversa

    ..................................
    Attached Files Attached Files

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

    Re: UserForm if checkbox is checked then check the others and viceversa

    Try
    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.

  17. #17
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: UserForm if checkbox is checked then check the others and viceversa

    Thank you very much. You helped me a lot

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

    Re: UserForm if checkbox is checked then check the others and viceversa

    I just realized that my code misses one of the conditions. Change the three subsidiary box code to.

    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: UserForm if checkbox is checked then check the others and viceversa

    That's working great. Thanks mikerickson

+ 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. [SOLVED] how to use if condition to check whether checkbox is checked
    By Bronx in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-12-2016, 02:47 AM
  2. [SOLVED] VBA UserForm.Value Check If User Form Buttons checked Not Working. Check Button on Open.
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-11-2016, 05:55 PM
  3. Replies: 1
    Last Post: 09-24-2015, 11:50 AM
  4. Need to Count number of Check Boxes checked on a userform
    By UMBiii in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-12-2014, 03:44 PM
  5. [SOLVED] Transfer Data from UserForm that their check box had checked!
    By MariaPap in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-06-2013, 01:08 PM
  6. [SOLVED] When checkbox is checked it does not copy to new sheet. Only if not checked using false
    By thelisa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2013, 07:59 AM
  7. Replies: 2
    Last Post: 12-19-2012, 11:23 PM

Tags for this Thread

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