A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

macro



 
 
Thread Tools Display Modes
  #1  
Old October 7th, 2003, 08:06 PM
kendra lewin
external usenet poster
 
Posts: n/a
Default macro

Is it possible to assign unique macros to individual items
in a "combo drop down box"? For example, I have 5 items
that a user can select in a combo box. I can only assign
one macro. This same macro runs for every selection. I
want to have a unique macro run depending on the selection.
  #2  
Old October 7th, 2003, 08:39 PM
Dan E
external usenet poster
 
Posts: n/a
Default macro

Kendra,

You can create your 5 macros, lets say for arguments sake
they were macro1, macro2, ... macro5
You can use your combobox change event to run those 5
macros (so essentially each item has it's own macro, but
they are all fired from the same Combobox_Change event)

If you had Combobox1 and all the names of the possible
selections were "Item1", "Item2", ... "Item5" (ie that's what
the user clicks on).

And here I would like to suggest that
since you are using a combobox change event, you may
want to set the Style property of your combobox to
fmStyleDropDownList (disallows user typing in an input and
avoids the combobox change event from firing each time a
character is typed in the combobox. NOTE: I've assumed
that you used a combo box from the control toolbox not
the forms toolbox.

Anyways, here is the sample code...

Private Sub ComboBox1_Change()
UserIn = ComboBox1.Value
A = ComboBox1.Index
Select Case UserIn
Case "Item1"
Macro1
Case "Item2"
Macro2
Case "Item3"
Macro3
Case "Item4"
Macro4
Case "Item5"
Macro5
End Select
End Sub

Please note that the macros should be placed in the same
code window as the combobox change event.

Dan E

"kendra lewin" wrote in message ...
Is it possible to assign unique macros to individual items
in a "combo drop down box"? For example, I have 5 items
that a user can select in a combo box. I can only assign
one macro. This same macro runs for every selection. I
want to have a unique macro run depending on the selection.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:49 PM.


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