+ Reply to Thread
Results 1 to 6 of 6

Checkboxes to enable button

Hybrid View

  1. #1
    Registered User
    Join Date
    07-03-2014
    Location
    Chino Hills, CA
    MS-Off Ver
    2007/2010
    Posts
    3

    Checkboxes to enable button

    Hey community,

    First time posting here and its been a couple days trying to figure this macro out. Before flaming, I'm pretty new at VBA/Macros and have done extensive research. I have a series of 4 checkboxes that needs to be checked off before a button is enabled to be pushed. For some reason I cant find the resolution or make this work.

    This is what I have so far:

    Private Sub CheckBox1_Click()
        If CheckBox1 Then
        ActiveSheet.Button4.Enabled = True
     Else
        If Not CheckBox2 And Not CheckBox3 Then
        ActiveSheet.Button4.Enabled = False
     End If
     End Sub
     Private Sub CheckBox2_Click()
        If CheckBox1 Then
        ActiveSheet.Button4.Enabled = True
     Else
        If Not CheckBox3 And Not CheckBox4 Then
        ActiveSheet.Button4.Enabled = False
     End If
     End Sub
     Private Sub CheckBox3_Click()
        If CheckBox1 Then
        ActiveSheet.Button4.Enabled = True
     Else
        If Not CheckBox4 And Not CheckBox1 Then
        ActiveSheet.Button4.Enabled = False
     End If
     End Sub
     Private Sub CheckBox4_Click()
        If CheckBox1 Then
        ActiveSheet.Button4.Enabled = True
     Else
        If Not CheckBox1 And Not CheckBox2 Then
        ActiveSheet.Button4.Enabled = False
     End If
     End Sub
    With that...Flame suit on!

    Thanks for your help.

    -Ryan
    Last edited by ryryAP2; 07-11-2014 at 04:03 PM.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Checkboxes to enable button

    there wont be any flaming here
    is this in a form or on worksheet itself?

    also please put code in your post
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button). The result will appear like this in the post window:


    see attached example of checkbox checking before enabling commandbutton in a Form

    ps did not put any code to disable the button once you uncheck a checkbox
    so once its enabled..it stays that way
    Attached Files Attached Files
    Last edited by humdingaling; 07-10-2014 at 11:35 PM.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    07-03-2014
    Location
    Chino Hills, CA
    MS-Off Ver
    2007/2010
    Posts
    3

    Re: Checkboxes to enable button

    Thanks for the pointers. Let me try it on this point lol.


    This would be on a worksheet itself. I am trying to keep a button disabled, until my associates have checkboxed all 4 on the worksheet.

    Private Sub CheckBox1_Click()
        If CheckBox1 Then
        ActiveSheet.Button4.Enabled = True
     Else
        If Not CheckBox2 And Not CheckBox3 Then
        ActiveSheet.Button4.Enabled = False
     End If
     End Sub
     Private Sub CheckBox2_Click()
        If CheckBox1 Then
        ActiveSheet.Button4.Enabled = True
     Else
        If Not CheckBox3 And Not CheckBox4 Then
        ActiveSheet.Button4.Enabled = False
     End If
     End Sub
     Private Sub CheckBox3_Click()
        If CheckBox1 Then
        ActiveSheet.Button4.Enabled = True
     Else
        If Not CheckBox4 And Not CheckBox1 Then
        ActiveSheet.Button4.Enabled = False
     End If
     End Sub
     Private Sub CheckBox4_Click()
        If CheckBox1 Then
        ActiveSheet.Button4.Enabled = True
     Else
        If Not CheckBox1 And Not CheckBox2 Then
        ActiveSheet.Button4.Enabled = False
     End If
     End Sub
    Last edited by ryryAP2; 07-10-2014 at 11:54 PM.

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

    Re: Checkboxes to enable button

    Sub SetCommandButton()
    With ActiveSheet
        .CommandButton1.Enabled = .CheckBox1.Value And CheckBox2.Value And CheckBox3.Value And .CheckBox4.Value
    End With
    End Sub
    Have each of your CheckBox_Click events call that sub.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    07-03-2014
    Location
    Chino Hills, CA
    MS-Off Ver
    2007/2010
    Posts
    3

    Re: Checkboxes to enable button

    hmmm, still not working using that code.

    Thanks for the input guys!

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Checkboxes to enable button

    using mikes suggestion
    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. [SOLVED] Button enable and disable...
    By Will03 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-25-2013, 10:00 AM
  2. [SOLVED] enable a disabled button
    By CharlieZangel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2012, 07:32 PM
  3. Command button Enable using VBA
    By psatkar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-10-2006, 05:50 AM
  4. Using Checkboxes to enable/disable vb
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-15-2006, 12:45 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