Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run a macro when new selection in listbox

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Run a macro when new selection in listbox

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

-----Original Message-----
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
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox selection ub Excel Discussion (Misc queries) 0 March 10th 09 06:43 PM
protect cells after listbox selection Chay Excel Discussion (Misc queries) 2 December 2nd 06 11:32 PM
protect cells after listbox selection Chay Excel Discussion (Misc queries) 0 November 30th 06 06:49 PM
protect cells after listbox selection JLatham Excel Discussion (Misc queries) 0 November 30th 06 03:00 PM
Listbox & Selection sparx Excel Discussion (Misc queries) 0 July 31st 06 10:48 PM


All times are GMT +1. The time now is 04:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"