list box dialogue msgbox

  • Thread starter Thread starter Eileen
  • Start date Start date
E

Eileen

I have a list box, and when a different option is chosen from the list, I
need to either

a) create a macro that pops up a dialogue box to remind the user to press
some buttons to update the data,

or

b) create a macro that just goes ahead and updates the data.

I've already written the macros to update the data, I just can't figure out
how to join it up with the action of choosing a different option from the
list box. Any ideas?

Thanks in advance for your help.
 
Can you not just use the Change event of the listbox?

Private Sub ListBox1_Change()
'your update code here
End Sub
 
I have a list box, and when a different option is chosen from the list, I
need to either

a) create a macro that pops up a dialogue box to remind the user to press
some buttons to update the data,

or

b) create a macro that just goes ahead and updates the data.

I've already written the macros to update the data, I just can't figure out
how to join it up with the action of choosing a different option from the
list box. Any ideas?

Thanks in advance for your help.

You need to create a Change handler routine in the UserForm (or
worksheet) code module, something like this ...

Private Sub ListBox1_Change()
'Your handler code goes here (or invoke its subroutine)
msgbox "Press the buttons"
End Sub

The name of the Sub needs to match your control's name.

See the Excel help for the Events associated with the control for more
information and examples.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
 
You could put an algorithm in the listbox click event like:

If listbox1.Selected(0) Then
Macro1
ElseIf listbox1.Selected(1) Then
Macro2
ElseIf listbox1.Selected(2) Then
Macro3
End if

Of course, if the list box has a large number of items in it, this might not
be practical.
 
That worked brilliantly, thanks!

JW said:
Can you not just use the Change event of the listbox?

Private Sub ListBox1_Change()
'your update code here
End Sub
 
Back
Top