![]() |
triggering different macros from list box?
Hi ,
I have a list box populated with 5 items, lets call them Monday-Friday, how can I trigger I separate macro , on each selection , rather than the default one for the listbox. Any help will be gratefully received. Cheers Jamie -- --------------------------------------------------------------------- "Are you still wasting your time with spam?... There is a solution!" Protected by GIANT Company's Spam Inspector The most powerful anti-spam software available. http://www.giantcompany.com |
triggering different macros from list box?
You can use a Select Case statement in your default procedure which uses the
return value to run a specified procedure. -- David Hager Excel FMVP "hammer" wrote in message ... Hi , I have a list box populated with 5 items, lets call them Monday-Friday, how can I trigger I separate macro , on each selection , rather than the default one for the listbox. Any help will be gratefully received. Cheers Jamie -- --------------------------------------------------------------------- "Are you still wasting your time with spam?... There is a solution!" Protected by GIANT Company's Spam Inspector The most powerful anti-spam software available. http://www.giantcompany.com |
triggering different macros from list box?
Hi Jamie
You can't. You let the only default one decide which one to call from itself, like this: Select Case Listbox1.Listindex Case 0 Call Macro15 Case 1 Call Macro306 Case 2 Call YourParents Case Else Call FormatHarddrive End Select -- HTH. Best wishes Harald Followup to newsgroup only please. "hammer" wrote in message ... Hi , I have a list box populated with 5 items, lets call them Monday-Friday, how can I trigger I separate macro , on each selection , rather than the default one for the listbox. Any help will be gratefully received. Cheers Jamie -- --------------------------------------------------------------------- "Are you still wasting your time with spam?... There is a solution!" Protected by GIANT Company's Spam Inspector The most powerful anti-spam software available. http://www.giantcompany.com |
triggering different macros from list box?
Run a Select Case statement based on the ListBox value, within the
Lisbox_Click procedure. HTH Roger Shaftesbury (UK) "hammer" wrote in message ... Hi , I have a list box populated with 5 items, lets call them Monday-Friday, how can I trigger I separate macro , on each selection , rather than the default one for the listbox. Any help will be gratefully received. Cheers Jamie -- --------------------------------------------------------------------- "Are you still wasting your time with spam?... There is a solution!" Protected by GIANT Company's Spam Inspector The most powerful anti-spam software available. http://www.giantcompany.com |
triggering different macros from list box?
Sorry i should clarify I want to do this within excel, I don't know much
VB , Simple instructions would help. cheers all thanks for swift reply . jamie -- --------------------------------------------------------------------- "Are you still wasting your time with spam?... There is a solution!" Protected by GIANT Company's Spam Inspector The most powerful anti-spam software available. http://www.giantcompany.com "hammer" wrote in message ... Hi , I have a list box populated with 5 items, lets call them Monday-Friday, how can I trigger I separate macro , on each selection , rather than the default one for the listbox. Any help will be gratefully received. Cheers Jamie -- --------------------------------------------------------------------- "Are you still wasting your time with spam?... There is a solution!" Protected by GIANT Company's Spam Inspector The most powerful anti-spam software available. http://www.giantcompany.com |
triggering different macros from list box?
"hammer" wrote in message
... Sorry i should clarify I want to do this within excel, I don't know much VB , Simple instructions would help. Is the list in a spreadsheet or a userform or a dialog sheet ? Is it from the Forms toolbar or from the controls toolbax ? How do you populate your list, is it a macro too ? When do you want the macro to run, on clicking/arrowing to an item in the list or on clicking an OK button after that ? Apoliges for asking all this, but detailed info needs detailed background. -- HTH. Best wishes Harald Followup to newsgroup only please. |
triggering different macros from list box?
ok , thanks for help I will try to explain best I can,
the listbox is in a spreadsheet and is from the controls toolbox, I have typed in the 5 entries, and I would like the macro to run with the entry is highlighted/clicked on. Thanks again for the help, greatly appreciated Jamie -- --------------------------------------------------------------------- "Are you still wasting your time with spam?... There is a solution!" Protected by GIANT Company's Spam Inspector The most powerful anti-spam software available. http://www.giantcompany.com "Harald Staff" wrote in message ... "hammer" wrote in message ... Sorry i should clarify I want to do this within excel, I don't know much VB , Simple instructions would help. Is the list in a spreadsheet or a userform or a dialog sheet ? Is it from the Forms toolbar or from the controls toolbax ? How do you populate your list, is it a macro too ? When do you want the macro to run, on clicking/arrowing to an item in the list or on clicking an OK button after that ? Apoliges for asking all this, but detailed info needs detailed background. -- HTH. Best wishes Harald Followup to newsgroup only please. |
triggering different macros from list box?
In design mode, rightclick the listbox, choose View Code, paste the following into the
blank (?) sheet module that appear: Private Sub ListBox1_Click() Select Case ListBox1.ListIndex Case 0 Call Macro1 Case 1 Call Macro2 Case Else Beep End Select End Sub Sub Macro1() MsgBox "Yo" End Sub Sub Macro2() MsgBox "Cheers" End Sub Replace "ListBox1" with whatever name the listbox has. And Macro1, 2 actions with what you want done. -- HTH. Best wishes Harald Followup to newsgroup only please. "hammer" wrote in message ... ok , thanks for help I will try to explain best I can, the listbox is in a spreadsheet and is from the controls toolbox, I have typed in the 5 entries, and I would like the macro to run with the entry is highlighted/clicked on. |
triggering different macros from list box?
Well I am amazed at the speed and helpfulness of this group.
many thanks Jamie :) -- --------------------------------------------------------------------- "Are you still wasting your time with spam?... There is a solution!" Protected by GIANT Company's Spam Inspector The most powerful anti-spam software available. http://www.giantcompany.com "Harald Staff" wrote in message ... In design mode, rightclick the listbox, choose View Code, paste the following into the blank (?) sheet module that appear: Private Sub ListBox1_Click() Select Case ListBox1.ListIndex Case 0 Call Macro1 Case 1 Call Macro2 Case Else Beep End Select End Sub Sub Macro1() MsgBox "Yo" End Sub Sub Macro2() MsgBox "Cheers" End Sub Replace "ListBox1" with whatever name the listbox has. And Macro1, 2 actions with what you want done. -- HTH. Best wishes Harald Followup to newsgroup only please. "hammer" wrote in message ... ok , thanks for help I will try to explain best I can, the listbox is in a spreadsheet and is from the controls toolbox, I have typed in the 5 entries, and I would like the macro to run with the entry is highlighted/clicked on. |
triggering different macros from list box?
Glad it worked Jamie.
Best wishes Harald Followup to newsgroup only please. "hammer" wrote in message ... Well I am amazed at the speed and helpfulness of this group. many thanks Jamie :) |
All times are GMT +1. The time now is 04:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com