list box dialogue msgbox

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.
 
J

JW

Can you not just use the Change event of the listbox?

Private Sub ListBox1_Change()
'your update code here
End Sub
 
T

T Lavedas

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/
 
J

JLGWhiz

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.
 
E

Eileen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top