Having A Macro Run When A Selection Is Made In A List Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

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

Back
Top