PC Review


Reply
Thread Tools Rate Thread

assign a macro to a combo box

 
 
=?Utf-8?B?ZGF2ZSBjYWl6bGV5?=
Guest
Posts: n/a
 
      19th Sep 2007
Hi

I'm a fairly new user to Macros

I have a worksheet created in XL2003 that contains five buttons created from
the toolbox. Each button successfully runs its own unique macro basically
hiding and showing specific rows. The Macros are caller Sub Macro1( ) to Sub
Macro5( )

Having just come accross Combo boxes where the source data is allocated a
numerical value ie "One"=1, "Two"=2 etc, I would like to allocate Sub Macro1(
) to "One" and Sub Macro2( ) to "Two" etc. so that I can save a lot of space
in my workbook

How can I do this please

Many thanks
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      19th Sep 2007
You can link a cell to your combo box. That cell will then contain the index
of the item selected. Assuming you link to Cell A1 this code should work for
you...

Sub ComboCode()
Select Case Range("A1").Value
Case 1
Call Macro1
Case 2
Call Macro2
Case 3
Call Macro3
Case 4
Call Macro4
Case 5
Call Macro5
End Select
End Sub
--
HTH...

Jim Thomlinson


"dave caizley" wrote:

> Hi
>
> I'm a fairly new user to Macros
>
> I have a worksheet created in XL2003 that contains five buttons created from
> the toolbox. Each button successfully runs its own unique macro basically
> hiding and showing specific rows. The Macros are caller Sub Macro1( ) to Sub
> Macro5( )
>
> Having just come accross Combo boxes where the source data is allocated a
> numerical value ie "One"=1, "Two"=2 etc, I would like to allocate Sub Macro1(
> ) to "One" and Sub Macro2( ) to "Two" etc. so that I can save a lot of space
> in my workbook
>
> How can I do this please
>
> Many thanks

 
Reply With Quote
 
=?Utf-8?B?ZGF2ZSBjYWl6bGV5?=
Guest
Posts: n/a
 
      20th Sep 2007
Hi Jim

Thanks for the reply

This takes me part way to where I would like to get to and is workable for
me. I can just create a Run macro button.

However, my ideal solution would be that in having selected 3 from the combo
box drop down, the selection of that choice would run macro3.

Is this possible or am I asking for too much

Thanks

Dave

"Jim Thomlinson" wrote:

> You can link a cell to your combo box. That cell will then contain the index
> of the item selected. Assuming you link to Cell A1 this code should work for
> you...
>
> Sub ComboCode()
> Select Case Range("A1").Value
> Case 1
> Call Macro1
> Case 2
> Call Macro2
> Case 3
> Call Macro3
> Case 4
> Call Macro4
> Case 5
> Call Macro5
> End Select
> End Sub
> --
> HTH...
>
> Jim Thomlinson
>
>
> "dave caizley" wrote:
>
> > Hi
> >
> > I'm a fairly new user to Macros
> >
> > I have a worksheet created in XL2003 that contains five buttons created from
> > the toolbox. Each button successfully runs its own unique macro basically
> > hiding and showing specific rows. The Macros are caller Sub Macro1( ) to Sub
> > Macro5( )
> >
> > Having just come accross Combo boxes where the source data is allocated a
> > numerical value ie "One"=1, "Two"=2 etc, I would like to allocate Sub Macro1(
> > ) to "One" and Sub Macro2( ) to "Two" etc. so that I can save a lot of space
> > in my workbook
> >
> > How can I do this please
> >
> > Many thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
assign a macro to a combo box =?Utf-8?B?ZGF2ZSBjYWl6bGV5?= Microsoft Excel Misc 0 19th Sep 2007 11:08 AM
Assign macro to each item of a drop-down list or combo box - how? jbp20717 Microsoft Excel Programming 1 27th Jul 2005 11:17 AM
How to assign a value to a combo box? Paul Microsoft Access Forms 3 21st Mar 2005 01:48 AM
Combo box. How do I assign a value? Frank Martin Microsoft Access Forms 4 30th Dec 2003 10:37 PM
Can't assign value to combo box Mike Collard Microsoft Access Forms 3 13th Nov 2003 03:15 PM


Features
 

Advertising
 

Newsgroups
 


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