LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Running a macro based on combo box value


It's working!! I'm so happy! Thank you!!

Leith Ross Wrote:
Hello m3s3lf,

If I understand you correctly, this macro should work. This exampl
uses a Forms Drop Down with 3 lines for brevity. You can expand thi
example to run as many macros as you have entries.

First copy this code using CTRL+C then insert a VBA Module into you
Workbook's Project. Paste the code into the new Module. Add the name
of the macros to be called into the Select Case code below each Cas
statement. Be sure to save your changes using CTRL+S.

Link this Macro to the Drop Down. When the user makes a selection, th
macro will determine which line number was selected in the Drop Down
This line number then determines which macro will be executed.


Code
-------------------
Sub RunMacrosFromDropDown()


'Get the Name of ComboBox (Drop Down)
Cbo = Application.Caller

'Get the line number of the entry and the entry data
With ActiveSheet.Shapes(Cbo).ControlFormat
CboLine = .ListIndex
CboData = .List(CboLine)
End With

'Select Macro to run based on the Drop Down line selected
Select Case CboLine
Case 1
'Call First Macro
Case 2
'Call Second Macro
Case 3
'Call Third Macro
End Select

End Sub

-------------------


Sincerely,
Leith Ros


--
m3s3l
-----------------------------------------------------------------------
m3s3lf's Profile: http://www.excelforum.com/member.php...fo&userid=3487
View this thread: http://www.excelforum.com/showthread.php?threadid=55287

 
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
Running a macro based on the time WNYC Excel Discussion (Misc queries) 1 March 22nd 10 09:45 PM
In Excel I need to set up a combo box based on another combo box. donna_ge Excel Discussion (Misc queries) 2 March 29th 06 03:26 PM
Running a macro based on a value Jeanne Conroy Excel Programming 3 March 15th 06 10:19 PM
Macro to automate page protection based on combo box reply wongard Excel Discussion (Misc queries) 9 September 9th 05 06:47 AM
Running a macro based on a cells value Piwo Excel Programming 4 April 18th 05 08:28 PM


All times are GMT +1. The time now is 12:14 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"