+ Reply to Thread
Results 1 to 3 of 3

Problem When Setting Checkbox Values

Hybrid View

rcoates Problem When Setting Checkbox... 06-10-2009, 02:41 AM
DonkeyOte Re: Problem When Setting... 06-10-2009, 03:33 AM
rcoates Re: Problem When Setting... 06-10-2009, 06:44 PM
  1. #1
    Registered User
    Join Date
    06-10-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Problem When Setting Checkbox Values

    Hello,

    This is my first post, I hope someone can help me :-)

    I have created some activex checkboxes on a worksheet.

    When they are ticked (or unticked), a function is called. For example if the checkbox name was "ManualCharging", it calls a function ManualCharging_Click()

    That's fine.

    The only issue is that at times I would like (elsewhere in my VBA code) to change the value of "ManualCharging" using the code line ManualCharging.value = false, but without calling the click function ManualCharging_Click(). I want that one to only be called when a user actually uses the mouse to tick or untick the checkbox.

    Is there any way to do that? Is there another call besides ManualCharging.value = false to do that?

    I've managed to work it so my project still works even with this unwanted effect, it's just that it's not very efficient because lines of code are being called that aren't required - esp. for some checkboxes which in turn call other functions with nested loops etc.

    Thanking you all kindly in advance!

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Problem When Setting Checkbox Values

    What you're referring to is the disabling/enabling of Events.

    You can for ex. disable events @ Application level before altering the checkbox value such that the change event is not invoked, subsequently enabling events such that going forward clicking it manually does invoke the handler, eg:

    Handler:

    Private Sub CheckBox1_Click()
    MsgBox "Hello"
    End Sub
    Other Routine to alter Checkbox but not to invoke Handler

    Public Sub Example()
    Application.EnableEvents = False
    CheckBox1.Value = True
    Application.EnableEvents = True
    End Sub

  3. #3
    Registered User
    Join Date
    06-10-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Problem When Setting Checkbox Values

    Thank you SO much!
    That's very much appreciated :-)

+ 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