Run a macro when new selection in listbox

  • Thread starter Thread starter Georg
  • Start date Start date
G

Georg

Hello

I have been struggling with a probable very basic task and
wonder if anyone could give me a hint. I have a worksheet
that contains a listbox. Every time the user changes the
selection of th listbox, I would like a macro to start
running. I have tried to use "Private Sub
Workbook_Calculate()". This does not seem to work when the
list choices are altered. Neither does the workbook.change
() seem to work.

Is there an easy way to initiate this when the user has
clicked on the control? And if so, how should I refer to
the listbox (I think it is called "list box 3").

Would be grateful for any hints.

Regards

G E O R G
 
If you use the listbox from the Form's tool bar, then
right click on the listbox, select assign macro then
click NEW. This takes you to yhje code window with the
default procedure frame , just ass a call to your macro.
eg if your macro is called MyCode add 'Call MyCode' as
below:
Sub ListBox1_Change()
Call MyCode
End Sub


If your listbox is from the ActiveX toolbar (The Control
Toolbox) then right click on kit and hit View Code
again this takes you to the control's event handler, so
all you need to do is add the same call viz
Private Sub ListBox1_Click()
Call MyOtherSub
End Sub


Patrick Molloy
Microsoft Excel MVP
 
Back
Top