MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Feb 25th, 2002, 09:45 PM   #1
greg0226
New Member
 
Join Date: Feb 2002
Location: Benicia, CA
Posts: 31
Default

Hi. I am trying to make a combobox of three values. Each time you select one of the options it will perform a macro. If anyone can help this would be great. I am trying to get the first option to print the first page, 2nd option will print the first two pages. The 3rd option will print all three pages. Any help would be great. thanks.

Greg
greg0226 is offline   Reply With Quote
Old Feb 26th, 2002, 10:00 AM   #2
Russell Hauf
MrExcel MVP
 
Russell Hauf's Avatar
 
Join Date: Feb 2002
Location: Portland, OR USA
Posts: 1,374
Default

Quote:
On 2002-02-25 20:45, greg0226 wrote:
Hi. I am trying to make a combobox of three values. Each time you select one of the options it will perform a macro. If anyone can help this would be great. I am trying to get the first option to print the first page, 2nd option will print the first two pages. The 3rd option will print all three pages. Any help would be great. thanks.

Greg
Have you solved this? If not, can you tell me which ComboBox you are using? (did you create it from the Forms toolbar, or the Control Toolbox toolbar)

-rh
Russell Hauf is offline   Reply With Quote
Old Feb 26th, 2002, 06:49 PM   #3
greg0226
New Member
 
Join Date: Feb 2002
Location: Benicia, CA
Posts: 31
Default

I am using the Combobox from the Control Toolbox. I have not been able to solve this problem yet, so if you can help that would be awesome. thanks.
greg0226 is offline   Reply With Quote
Old Feb 26th, 2002, 08:33 PM   #4
turbotoan
Board Regular
 
Join Date: Feb 2002
Location: Wisconsin - USA
Posts: 62
Default

Hi there,
I haven't played with selected pages, but you can definitely add a Choose Case statement into the script behind the combobox. From the VBA editor...under the Project Explorer, drill down to the Form you have this combobox listed.
Then, left-Double-click on the combobox field. You should automatically be placed in a script window with the name of the combobox & the _change...
i.e. Private Sub cboAssignNm_Change()
End Sub
In this script, define variables & place your case statement.

As for the printing...
See this example..
- Worksheets(strWorksheetName).Activate - ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
turbotoan is offline   Reply With Quote
Old Feb 26th, 2002, 08:51 PM   #5
greg0226
New Member
 
Join Date: Feb 2002
Location: Benicia, CA
Posts: 31
Default

Sorry I dont think i was really clear on my question. The problem that i am having is trying to get the options to run the macros. I can't write the script right or something. Not sure how to go about it. If anyone can help with this, that would be great. Thanks for replying everyone though.

Greg
greg0226 is offline   Reply With Quote
Old Feb 27th, 2002, 01:03 AM   #6
Barfbagger
New Member
 
Join Date: Feb 2002
Location: Whitchurch, England
Posts: 7
Default

A combo box has a linked cell. A combobox from the forms toolbox (known as a dropdown box) returns an integer while the control toolbox returns a string. When you select from a combo list it changes the value in the linked cell. Try this:

Create a new sheet and type "red" "blue" and "green" in cells A1 to A3.
Open the forms toolbox and create a combobox on the worksheet right click and select Format Control. Got to the Control tab and enter A1:A3 for the input range, G12 for the linked cell. OK. Right click again and select Assign Macro, type in "Dropdown1_change"
Open the Controls toolbox and create another combobox on the worksheet. Right click and select properties. Find the LinkedCell property and enter G15, find the ListFillRange and enter A1:A3. Now right click and select View Code then Change from the righthand dropdown list.
Enter

Application.Run Range("g15").Text

between the Private Sub and End Sub.

Now enter the following into a macro module for the work book


Sub Macro1()
Application.Run "Red"
End Sub

Sub Macro2()
Application.Run "Blue"
End Sub

Sub Macro3()
Application.Run "Green"
End Sub

Sub Red()
Range("a10:b15").Select
With Selection.Interior
.ColorIndex = 3
End With
End Sub

Sub Blue()
Range("a10:b15").Select
With Selection.Interior
.ColorIndex = 5
End With
End Sub

Sub Green()
Range("a10:b15").Select
With Selection.Interior
.ColorIndex = 4
End With
End Sub

Sub Dropdown1_change()
Dim intChoice As Integer
Dim strChoice As String
intChoice = Range("G12").Value
strChoice = Trim(Str(intChoice))
Application.Run "Macro" & strChoice
End Sub


Close the toolboxes and try them out


[ This Message was edited by: Barfbagger on 2002-02-27 00:05 ]

[ This Message was edited by: Barfbagger on 2002-02-27 00:06 ]

[ This Message was edited by: Barfbagger on 2002-02-27 01:38 ]
Barfbagger is offline   Reply With Quote
Old Feb 27th, 2002, 01:57 AM   #7
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

Quote:
On 2002-02-26 19:51, greg0226 wrote:
Sorry I dont think i was really clear on my question. The problem that i am having is trying to get the options to run the macros. I can't write the script right or something. Not sure how to go about it. If anyone can help with this, that would be great. Thanks for replying everyone though.

Greg
Try something along these lines for your
combobox code;

Private Sub ComboBox1_Change()

Select Case ComboBox1.ListIndex + 1

Case Is = 1
MsgBox "1"
Case Is = 2
MsgBox "2"
Case Is = 3
MsgBox "3"
End Select
End Sub

HTH

Ivan

Private Sub ComboBox1_DropButt*******()
Dim x
If ComboBox1.ListIndex = -1 Then
For x = 1 To 3
ComboBox1.AddItem x
Next
End If
End Sub
Ivan F Moala is offline   Reply With Quote
Old Feb 27th, 2002, 09:45 AM   #8
greg0226
New Member
 
Join Date: Feb 2002
Location: Benicia, CA
Posts: 31
Default

Thanks everyone. I got it to work. I appreciate all the responses.

Greg
greg0226 is offline   Reply With Quote
Old Feb 27th, 2002, 07:23 PM   #9
mdennis624
New Member
 
Join Date: Feb 2002
Location: York, PA
Posts: 16
Default

Hi Gregg,

I'm trying to do the same thing using a combo box to run other macros. What code did you substitute for the [MsgBox "1", "2",etc] line in the last example from Ivan? I'm having trouble getting the right code to call the macros. Thank you, Mike D.

[ This Message was edited by: mdennis624 on 2002-02-27 18:24 ]
mdennis624 is offline   Reply With Quote
Old Feb 27th, 2002, 07:40 PM   #10
Juan Pablo González
MrExcel MVP
 
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
Default

It should read then

Case 1
YourMacro1
Case 2
YourMacro2
Case 3
...

and so on.
__________________
Regards,

Juan Pablo González
http://www.juanpg.com
Juan Pablo González is offline   Reply With Quote
Reply

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 01:50 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes