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 Mar 8th, 2002, 05:15 AM   #1
Guest
 
Posts: n/a
Default


How do I get it to appear in a cell? Just supposing I want it go into cell reference a1?
  Reply With Quote
Old Mar 8th, 2002, 05:16 AM   #2
Audiojoe
Board Regular
 
Join Date: Feb 2002
Location: Where the wild roses grow
Posts: 285
Default

Supposing your combobox is combobox1, and the sheet you want the answer in is Sheet1, you could use:

worksheets("sheet1").range("a1").value = combobox1

Audiojoe is offline   Reply With Quote
Old Dec 19th, 2002, 09:28 PM   #3
Yogi
Board Regular
 
Join Date: Oct 2002
Posts: 74
Default

Where would this formula be written?
Yogi is offline   Reply With Quote
Old Dec 20th, 2002, 03:35 AM   #4
voodoo
Board Regular
 
Join Date: Apr 2002
Location: Australia
Posts: 186
Default

Here one option. It will take whatever item you select in the combobox and place it in cell A1.

This assumes your combobox is placed on your worksheet and users the combo change event. Place this in the code module behind your sheet.

Private Sub comboBox1_Change()
Sheet1.Range("A1").Value = ComboBox1.Text
End Sub

voodoo is offline   Reply With Quote
Old Dec 20th, 2002, 03:58 AM   #5
Ekim
Board Regular
 
Join Date: Jun 2002
Location: Perth, Australia
Posts: 1,416
Default

If your Combo box is from the Toolbox menu, put a cell reference in the "LinkedCell" field. If the Combo Box is from the Form menu, put a cell reference in the "Cell Link" field. No macro is necessary. If you are not clear about this, post back.

Regards,

Mike
Ekim is offline   Reply With Quote
Old Dec 20th, 2002, 11:26 AM   #6
Yogi
Board Regular
 
Join Date: Oct 2002
Posts: 74
Default

My Combo button is on a form. I am not certain about the procedure linking the button to the cell. Please explain.
Thanks
Yogi is offline   Reply With Quote
Old Dec 20th, 2002, 01:48 PM   #7
Ekim
Board Regular
 
Join Date: Jun 2002
Location: Perth, Australia
Posts: 1,416
Default

Everyone assumed that you had a combo box in a worksheet not a combo box on a Form (big difference). Combo boxes in a worksheet have the linked cell procedure.

O.K. - let's start from scratch. To illustrate the procedure I will create some data. This is what I want to achieve:

1. Have a Combo Box and a Command button on a Form in Sheet 1 (I assume that since you already have a Combo Box on a Form, that you also know how to put a Command button on the same Form).
2. Populate the Combo Box from a list in a worksheet named "Data"
3. Get information from the Combo Box and put it in cell C5 on a worksheet named "Result".

Procedure:
1. Name a worksheet as "Data" and put the following list in A1:A6:


Tiger
Panther
Lion
Leopard
Puma
Cougar



2. Name the above list as "BigCats"
3. Name a worksheet as "Result"
4. On a Form (UserForm1), you will have a Combo Box (ComboBox1) and a Command button (CommandButton1). Single click CommandButton1, delete the words "CommandButton1" and enter the word "Cancel".
5. These are the macros that you will need:

Double click the Form, and put these macros in the module behind the Form:


Private Sub UserForm_Initialize()

With UserForm1.ComboBox1

.RowSource = Worksheets("Data").Range("BigCats").Address(external:=True)
'Set combo box to first entry
.ListIndex = 0

End With
End Sub

Private Sub ComboBox1_Change()
Worksheets("Result").Range("C5").Value = _
ComboBox1.Text
End Sub

Private Sub CommandButton1_Click()
Unload Me
End Sub



In a standard module, put:


Sub MyForm()
UserForm1.Show

End Sub



6. Select Sheet1, go to the View menu, select Toolbars then Forms. Select the Button
icon and assign the button to the MyForm macro.
7. Click the button referred to in item 6, select an item from the Combo Box, hit the Cancel button on the Form, then look at cell C5 on the Results worksheet.

Notes:
Look at the first macro. You could populate the Combo Box by using the following macro:


Private Sub UserForm_Initialize()

With UserForm1.ComboBox1
.AddItem "Tiger"
.AddItem "Panther"
.AddItem "Lion"
.AddItem "Leopard"
.AddItem "Puma"
.AddItem "Cougar"
'Set combo box to first entry
.ListIndex = 0
End With
End Sub



Personally, I think that the first macro is the easier method.

HTH

Mike

[ This Message was edited by: Ekim on 2002-12-20 12:54 ]
Ekim is offline   Reply With Quote
Old Dec 20th, 2002, 03:48 PM   #8
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

Comboboxes on a userform do have a 'linked cell' property, the ControlSource property. Right-click the combobox in design mode, find the ControlSource entry and type in the cell reference where you'd like the value to appear. As long as you have another control on the form, tabbing out of the combobox will enter it's value in the cell.
Mudface is offline   Reply With Quote
Old Dec 20th, 2002, 11:10 PM   #9
Ekim
Board Regular
 
Join Date: Jun 2002
Location: Perth, Australia
Posts: 1,416
Default

Mudface,

You are correct. When I wrote my reply last night (my time), I must have had my head up my .....

Using the data from my previous post, here's a simple answer to the OP's question.

1. Right click your combo box to bring up the Property window.
2. In RowSource field, put "BigCats" (without the apostrophes).
3. In the ControlSource field, put Sheet2!C5 (no "=" sign).

When are you going to get out of freezing cold, rainy, miserable Hull? Nice and warm in my hometown.

Regards,

Mike
Ekim is offline   Reply With Quote
Old Dec 21st, 2002, 11:04 AM   #10
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

Quote:
On 2002-12-20 22:10, Ekim wrote:
Mudface,

When are you going to get out of freezing cold, rainy, miserable Hull? Nice and warm in my hometown.
.
Mudface 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 05:18 PM.


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