Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    NJ, USA
    Posts
    239
    Thanks
    2
    Thanked 1 Time in 1 Post

    Interaction between userform controls (XL 2003 SP2)

    Does anyone have a clever/elegant way to stop events of userform controls from being triggerred? I often have userforms with a checkbox and a listbox, say, that are inter-related. If the user just makes a selection in the listbox, I want the checkbox to become checked. If the user unchecks the checkbox, then I want to deselect all items in the listbox. I basically need to distinguish between events being triggerred by direct user-initiated actions and those occurring "internally" (when I don't want the event to fire). I had hoped that Application.EnableEvents might do the trick, but it doesn't seem to apply.

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Interaction between userform controls (XL 2003 SP2)

    Edited by HansV to correct link

    See:

    http://www.jkp-ads.com/articles/noevents00.htm
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    NJ, USA
    Posts
    239
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Interaction between userform controls (XL 2003 SP2)

    Jan Karel - thanks (belatedly) for the quick reply. I was actually doing something similar, except I was using a userform variable, mblnGUI, that I was initializing to True. A couple of questions:
    (1) I have always defined global variables within a regular module (that I name GLOBALS). Is it better practice to define them in the ThisWorkbook module?
    (2) Even though NoEvents is defined as public, you referred to it as ThisWorkbook.NoEvents rather than just NoEvents. Is that necessary or just a matter of style?
    Thanks for your help.

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Interaction between userform controls (XL 2003 SP2)

    Variables declared as public in class modules are visible to the outside world. They are too if declared using "Dim", but I use "Public" to emphasize they are "publicly visible". But if you want to use a public variable from a class, you always have to prepend with the class's name. Only public variables declared in normal modules are visible without prepending the name of the module.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •