Results 1 to 4 of 4

How do I change a checkbox to unchecked without running the code within the checkbox

Threaded View

  1. #1
    Registered User
    Join Date
    08-07-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2010
    Posts
    9

    How do I change a checkbox to unchecked without running the code within the checkbox

    I have a macro I've written that has a checkbox on a userform. I'd like that checkbox to either start out as checked or not checked, depending on certain logic. I also have code that runs when I use the mouse to click the checkbox and switch it between checked and unchecked. The problem is, when I try to just change the value of the checkbox, it always runs the code within the checkbox, which I don't want unless it is clicked with a mouse.

    Here is a simplified version of my code (to get my point across)

    Sub test()
    If Range("K4") = "N/A" Then
    UserForm1.CheckBox1 = True 'Only want value changed, not the macro run as if the checkbox was clicked
    Else
    UserForm1.CheckBox1 = False
    End If
    End Sub




    'Code within UserForm
    Private Sub CheckBox1_Click()
    If CheckBox1 Then
    TestValue = 42
    End IF
    End Sub

    And help would be much appreciated, it's really frustrating.
    Last edited by jsunnb; 09-27-2012 at 12:47 PM.

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