Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveX Combo Box on Excel sheet 1

Status
Not open for further replies.

sjh

Programmer
Oct 29, 2001
263
US
Hi, this is a beginner question.
After I create a Combo box (control, not forms) on a excel sheet, where do I define the values for the combo box list? I looked at the properties, but I couldn't find the correct place for it. I want the values to come from another excel sheet (in the same workbook).

Thank you.
 
Thank you Skip for keep helping me out! ListFillRange worked like a charm.

Do you also know how to just enter the values for the combo box list - and not refer to the range on a sheet?
 
Where should I put the .AddItem code? Should it be under Worksheet.open event or something?

Thanks again. Sorry about keep coming up with new questions... :)
 
You will also want to clear the box if it was saved previously...
Code:
Private Sub Workbook_Open()
  With ComboBox1
    .Clear
    .AddItem "Apples"
    .AddItem "Pears"
...
  End With
End Sub
:)

Skip,
Skip@TheOfficeExperts.com
 
Hi,
For initializing variables in a worksheet, what event is more appropriate? I tried using Worksheet_Open method and wrote code for adding items to the combo box, but somehow this method doesn't seem to get called.

Thank you,

 
That's odd, it should do.

Try inserting this line into your Workbook_Open() event as a quick visual check. Save & reopen the file.

MsgBox ("Workbook_Open is running!")

Also, do you have Macro Security enabled? (Tools... Macros... Security...)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top