Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Accessing combobox/listbox values
This is a very basic question.. I have several Combo Boxes on one sheet with macros for each. I'm trying to change the selected item in one Combo Box based on the value of another. My problem is in accessing the Combo Box, I can't find any help on how to do it. The examples don't help, using something like: ComboBox1.AddItem "Duck" Gets me a "Object Required" error. I have the boxes 'named' "DropDown1", "DropDown2", etc. Specifically I'd like to do this: If I particular value is selected in one Combo Box, I'd like to set another Combo Box to a different value. Hmm, that doesn't sound informative, I'll try this: "DropDown1" has items of "none" and "SCSI". "DropDown2" has items of "none" and "SCSI controller model X" Both are at "none" by default, but when I select "SCSI" in the first box I want the second box to switch from "none" to "SCSI controller ...." automatically. I've tried this: Worksheets("Sheet1").ComboBox("DropDown2") etc. -- This is the part where I'm not doing something right (This particular example gets me "Object doesn't support this method".) How do I specifically reference a List Box or ComboBox by name (or whatever I need to do)? Thanks in advance for your help! ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Accessing combobox/listbox values
If you have your Comboboxes named Dropdown1, Dropdown2 then you cannot use
this: ComboBox1.AddItem "Duck" The error you are getting is because the code cannot find a combobox named Combobox1. Change it to: Dropdown1.AddItem "Duck" For the next problem, I don't know how you're doing your entries but I used this code to change the combobox 2 value based on the combobox 1 value. The only thing is this will require either a large IF statement if you have several items or you can use a Select Case method. For better results look in the Help for vlookup, I think that will be the best route. HTH "eggrock" wrote in message ... This is a very basic question.. I have several Combo Boxes on one sheet with macros for each. I'm trying to change the selected item in one Combo Box based on the value of another. My problem is in accessing the Combo Box, I can't find any help on how to do it. The examples don't help, using something like: ComboBox1.AddItem "Duck" Gets me a "Object Required" error. I have the boxes 'named' "DropDown1", "DropDown2", etc. Specifically I'd like to do this: If I particular value is selected in one Combo Box, I'd like to set another Combo Box to a different value. Hmm, that doesn't sound informative, I'll try this: "DropDown1" has items of "none" and "SCSI". "DropDown2" has items of "none" and "SCSI controller model X" Both are at "none" by default, but when I select "SCSI" in the first box I want the second box to switch from "none" to "SCSI controller .." automatically. I've tried this: Worksheets("Sheet1").ComboBox("DropDown2") etc. -- This is the part where I'm not doing something right (This particular example gets me "Object doesn't support this method".) How do I specifically reference a List Box or ComboBox by name (or whatever I need to do)? Thanks in advance for your help! ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Combobox/Listbox Difference | Excel Discussion (Misc queries) | |||
Combobox v Listbox | New Users to Excel | |||
Combobox/listbox | Excel Discussion (Misc queries) | |||
Combobox or Listbox | Excel Programming | |||
listbox-combobox category | Excel Programming |