I must be missing something completely obvious, but I am using the 'additem' function and when i click on the drop down icon on my combobox - nothing appears.
I've checked all the properties but still nothing.
Please help!
Printable View
I must be missing something completely obvious, but I am using the 'additem' function and when i click on the drop down icon on my combobox - nothing appears.
I've checked all the properties but still nothing.
Please help!
If you cannot solve this I suggest you copy/paste the code you are using. This code adds open workbook names to a combobox.
'------------------------------------------------
Sub ReSetBookCombo()
FindForm.BookCombo.Clear
For Each wb In Workbooks
FindForm.BookCombo.AddItem (wb.Name)
Next
'FindForm.BookCombo.ListIndex = 0
End Sub
'---------------------------------------------------------
Thanks Brian,
Under the workbook 'Open' event, I have entered the following code:
Private Sub Workbook_Open()
cmbPeriod.AddItem = "P1"
End Sub
However, when the workbook opens there is nothing in the comboBox, and I don't know why.
Many thanks.
Aha. Looks like the CB is in a worksheet. I had assumed from your question that it was in a form. You are using the wrong method.
'------------------------------------------
If you used the Forms toolbar
right click the cb to get a menu.
Format Control
Control
In Input Range type A1 (or whatever). If you want more items make a bigger range eg. A1:A10
'--------------------------------------------------
If you used the Controls toolbar (not recommended for numerous controls because there are bugs)
Get the Controls toolbar
Click on Design Mode Button
Click on Properties button
ListFillRange ... type A1
'-------------------------------------------------
You code should be something like :-
Code:Private Sub Workbook_Open()
Worksheets("Sheet1").Range("A1").Value= "P1"
End Sub