Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Having A Macro Run When A Selection Is Made In A List Box
I need to attach a macro to the list box, because there will be several list
box with same choices, but it take them to a different location. I am using Excel 2000. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Having A Macro Run When A Selection Is Made In A List Box
for a listbox from the control toolbox toolbar, put you code in the click
event of the listbox. with the sheet in design mode, double click on the listbox. for a listbox from the forms toolbar, write a macro and assign it to the listbox by right clicking on the listbox and selecting assign macro. in the macro you would have something like sub Listbox1_Click() Dim sName a sString, vVal as String dim lbox as Listbox sName = Application.Caller set lbox = activesheet.listboxes(sName) vVal = lbox.List(lbox.ListIndex) select Case lcase(vVal) case "house" macro1 case "work" macro2 case "car" macro3 End Select end Sub -- Regards, Tom Ogilvy "Compnerd" wrote in message ... I need to attach a macro to the list box, because there will be several list box with same choices, but it take them to a different location. I am using Excel 2000. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Having A Macro Run When A Selection Is Made In A List Box
I was not clear on What I want. I am trying to setup a Menu page that has 20
drop-down list that the user can select by the style number and color. When they make the choice, it will take them to a worksheet. One of the drop-down list would say 770 with the color choices of Red-White, Forest-White, or Navy-White. I would like to use Control Toolbox Combination Box-change the Style property to 2 and write my Macro like these Sub redwhite770() ' ' redwhite770 Macro ' ' Sheets("770rw").Select End Sub I need the code for the combo box that when user select the color it will run the Macro. "Tom Ogilvy" wrote: for a listbox from the control toolbox toolbar, put you code in the click event of the listbox. with the sheet in design mode, double click on the listbox. for a listbox from the forms toolbar, write a macro and assign it to the listbox by right clicking on the listbox and selecting assign macro. in the macro you would have something like sub Listbox1_Click() Dim sName a sString, vVal as String dim lbox as Listbox sName = Application.Caller set lbox = activesheet.listboxes(sName) vVal = lbox.List(lbox.ListIndex) select Case lcase(vVal) case "house" macro1 case "work" macro2 case "car" macro3 End Select end Sub -- Regards, Tom Ogilvy "Compnerd" wrote in message ... I need to attach a macro to the list box, because there will be several list box with same choices, but it take them to a different location. I am using Excel 2000. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Having A Macro Run When A Selection Is Made In A List Box
Assume the name of the combobox is ComboBox770
Private Sub ComboBox770_Click() Case Combobox1.Value Case "Red-White" Sheets("770rw").Select Case "Forest-White" Sheets("770fw").Select Case "Navy-White" Sheets("770nw").Select End Select End Sub Changing the style would usually be done manually when you place the control. -- Regards, Tom Ogilvy "Compnerd" wrote in message ... I was not clear on What I want. I am trying to setup a Menu page that has 20 drop-down list that the user can select by the style number and color. When they make the choice, it will take them to a worksheet. One of the drop-down list would say 770 with the color choices of Red-White, Forest-White, or Navy-White. I would like to use Control Toolbox Combination Box-change the Style property to 2 and write my Macro like these Sub redwhite770() ' ' redwhite770 Macro ' ' Sheets("770rw").Select End Sub I need the code for the combo box that when user select the color it will run the Macro. "Tom Ogilvy" wrote: for a listbox from the control toolbox toolbar, put you code in the click event of the listbox. with the sheet in design mode, double click on the listbox. for a listbox from the forms toolbar, write a macro and assign it to the listbox by right clicking on the listbox and selecting assign macro. in the macro you would have something like sub Listbox1_Click() Dim sName a sString, vVal as String dim lbox as Listbox sName = Application.Caller set lbox = activesheet.listboxes(sName) vVal = lbox.List(lbox.ListIndex) select Case lcase(vVal) case "house" macro1 case "work" macro2 case "car" macro3 End Select end Sub -- Regards, Tom Ogilvy "Compnerd" wrote in message ... I need to attach a macro to the list box, because there will be several list box with same choices, but it take them to a different location. I am using Excel 2000. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro with List Box Selection | Excel Discussion (Misc queries) | |||
Combo box disappears after selection made | Excel Discussion (Misc queries) | |||
Starting a macro from a list selection | Excel Worksheet Functions | |||
Choices made available dependent on another selection? | Excel Worksheet Functions | |||
Macro to change list box input range based on selection made in another cell | Excel Programming |