ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   list box dialogue msgbox (https://www.excelbanter.com/excel-programming/410524-list-box-dialogue-msgbox.html)

Eileen

list box dialogue msgbox
 
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.

JW[_2_]

list box dialogue msgbox
 
Can you not just use the Change event of the listbox?

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

Eileen wrote:
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.


T Lavedas

list box dialogue msgbox
 
On May 6, 8:10 am, Eileen wrote:
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/

JLGWhiz

list box dialogue msgbox
 
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.

"Eileen" wrote:

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.


Eileen

list box dialogue msgbox
 
That worked brilliantly, thanks!

"JW" wrote:

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

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

Eileen wrote:
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.




All times are GMT +1. The time now is 07:19 AM.

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