Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can I assign a macro to each item in a drop-down list?


Is it possible to assign a different macro to each item in a drop down
list or not?

I've tried something like this, but I am totally useless with
VisualBasic, so I wouldn't be surprised if its totally meaningless:

Sub Larder2()
'
Select Case ("Larder Prep")
Sheets("Larder Prep").Select
Select Case ("Bakery")
Sheets("Bakery").Select
End Sub

...besides, I want to run a range of macros and not select sheets in
the workbook.


--
jbp20717
------------------------------------------------------------------------
jbp20717's Profile: http://www.excelforum.com/member.php...o&userid=24886
View this thread: http://www.excelforum.com/showthread...hreadid=384257

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Can I assign a macro to each item in a drop-down list?

No, but you could have the macro that fires when you select (I assume it is
a Forms listbox?) to test the value and fire the appropriate macro.

--
HTH

Bob Phillips

"jbp20717" wrote in
message ...

Is it possible to assign a different macro to each item in a drop down
list or not?

I've tried something like this, but I am totally useless with
VisualBasic, so I wouldn't be surprised if its totally meaningless:

Sub Larder2()
'
Select Case ("Larder Prep")
Sheets("Larder Prep").Select
Select Case ("Bakery")
Sheets("Bakery").Select
End Sub

..besides, I want to run a range of macros and not select sheets in
the workbook.


--
jbp20717
------------------------------------------------------------------------
jbp20717's Profile:

http://www.excelforum.com/member.php...o&userid=24886
View this thread: http://www.excelforum.com/showthread...hreadid=384257



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can I assign a macro to each item in a drop-down list?


How would I go about that? ;

--
jbp2071
-----------------------------------------------------------------------
jbp20717's Profile: http://www.excelforum.com/member.php...fo&userid=2488
View this thread: http://www.excelforum.com/showthread.php?threadid=38425

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Can I assign a macro to each item in a drop-down list?

Assign the macro to the listbox and add this code to that macro

Sheets(ActiveSheet.ListBoxes(Application.Caller).V alue).Select


But the sheet tabs at the bottom also have a list, just right-click the
arrow keys to the left of the tab names.

--
HTH

Bob Phillips

"jbp20717" wrote in
message ...

How would I go about that? ;)


--
jbp20717
------------------------------------------------------------------------
jbp20717's Profile:

http://www.excelforum.com/member.php...o&userid=24886
View this thread: http://www.excelforum.com/showthread...hreadid=384257



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Can I assign a macro to each item in a drop-down list?

This code should be assigned to the FORMS combo box, where cell D9 is the
linked cell. Each time you select a value, D9 gets that value and the code
runs.

Sub RunFromCellValue()
Application.Run Range("D9").Value
End Sub
the catch is that value must correspond to the code to be run

Alternative is to use an index
Sub RunFromCellValue()
select case range("D10") ' where D10 is the position of the selected item
case 1: Call MyProc_1
case 2: Call MyProc_2
case 3: Call Something else
Case Else
End Select
End Sub

If you're using the ActiveX combo box, then simply use the control's
listindex and use the select case method. Note , if the index is -1 then
nothing was selected.


"jbp20717" wrote:


Is it possible to assign a different macro to each item in a drop down
list or not?

I've tried something like this, but I am totally useless with
VisualBasic, so I wouldn't be surprised if its totally meaningless:

Sub Larder2()
'
Select Case ("Larder Prep")
Sheets("Larder Prep").Select
Select Case ("Bakery")
Sheets("Bakery").Select
End Sub

...besides, I want to run a range of macros and not select sheets in
the workbook.


--
jbp20717
------------------------------------------------------------------------
jbp20717's Profile: http://www.excelforum.com/member.php...o&userid=24886
View this thread: http://www.excelforum.com/showthread...hreadid=384257




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
Recording a macro to change item selected in drop down list Jen Excel Worksheet Functions 2 October 2nd 08 11:37 PM
ADD ITEM TO A DROP DOWN LIST? William Excel Discussion (Misc queries) 4 September 8th 08 09:05 PM
Running a macro when selecting an item in a drop-down list Christine Excel Discussion (Misc queries) 4 August 1st 08 08:50 PM
How to link macro to change an item in drop-down list Amotif Excel Discussion (Misc queries) 1 May 7th 08 01:55 PM
drop down list/typing item from list error Strike Eagle Loader[_2_] Excel Worksheet Functions 1 May 1st 07 06:35 PM


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

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

About Us

"It's about Microsoft Excel"