Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro with List Box Selection Karin Excel Discussion (Misc queries) 6 August 25th 09 05:12 PM
Combo box disappears after selection made Inquiringmind Excel Discussion (Misc queries) 0 February 13th 07 02:25 AM
Starting a macro from a list selection Rich_g Excel Worksheet Functions 3 December 1st 06 01:34 AM
Choices made available dependent on another selection? Miss Spaghetti Excel Worksheet Functions 1 April 21st 05 01:58 AM
Macro to change list box input range based on selection made in another cell Sue[_6_] Excel Programming 3 October 7th 04 06:45 PM


All times are GMT +1. The time now is 09:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"