ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Click event on listbox (https://www.excelbanter.com/excel-programming/326794-click-event-listbox.html)

IanC

Click event on listbox
 
I have a dialog that controls an interactive chart. This has a number of
listboxes, all of which have click events attached. When the user selects an
option in a box (say ListIndex = 4) that produces a combination of choices
that is not allowed, I need to revert the listbox to a permissible option
(say ListIndex =0).

Unfortunately, this just seems to create a new click event that, for some
reason, reverts the ListIndex back to the unpermissible option (i.e. 4) and
repeats the error.

Is there any way to stop these recurrent click events. I have tried using a
static boolean expression and disabling events, but it does not seem to to
stop the macro 'circling' at least twice.

Ian

Jim Thomlinson[_3_]

Click event on listbox
 
Application.enableevents = false

to turn events off. Be usre to turn them back on with

Application.enableevents = true

As these are application level evnet sit is a good idea to have an error
handler which resets the events in the event of a problem. Also when you are
debugging be carefule about stopping execution half way through. Your events
will be off and the code will seem to be not reacting as it should...

HTH

"IanC" wrote:

I have a dialog that controls an interactive chart. This has a number of
listboxes, all of which have click events attached. When the user selects an
option in a box (say ListIndex = 4) that produces a combination of choices
that is not allowed, I need to revert the listbox to a permissible option
(say ListIndex =0).

Unfortunately, this just seems to create a new click event that, for some
reason, reverts the ListIndex back to the unpermissible option (i.e. 4) and
repeats the error.

Is there any way to stop these recurrent click events. I have tried using a
static boolean expression and disabling events, but it does not seem to to
stop the macro 'circling' at least twice.

Ian


IanC

Click event on listbox
 
Many thanks.

The click event still repeats itself, but only after it has reached End Sub
for the first time. And its ListIndex still reverts at that stage to the
original (unpermissible) value. Taking out the change to ListIndex solves
the problem (so I am reasonably certain that is the problem), but still
leaves the original value showing in the ListBox.

"Jim Thomlinson" wrote:

Application.enableevents = false

to turn events off. Be usre to turn them back on with

Application.enableevents = true

As these are application level evnet sit is a good idea to have an error
handler which resets the events in the event of a problem. Also when you are
debugging be carefule about stopping execution half way through. Your events
will be off and the code will seem to be not reacting as it should...

HTH

"IanC" wrote:

I have a dialog that controls an interactive chart. This has a number of
listboxes, all of which have click events attached. When the user selects an
option in a box (say ListIndex = 4) that produces a combination of choices
that is not allowed, I need to revert the listbox to a permissible option
(say ListIndex =0).

Unfortunately, this just seems to create a new click event that, for some
reason, reverts the ListIndex back to the unpermissible option (i.e. 4) and
repeats the error.

Is there any way to stop these recurrent click events. I have tried using a
static boolean expression and disabling events, but it does not seem to to
stop the macro 'circling' at least twice.

Ian



All times are GMT +1. The time now is 01:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com