Results 1 to 4 of 4

Thread: Combo Box Problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    3

    Combo Box Problem

    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!

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Location
    Luton, UK
    Posts
    178
    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
    '---------------------------------------------------------
    Regards
    BrianB
    -------------------------------

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    3
    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.

  4. #4
    Addicted Member
    Join Date
    Aug 2002
    Location
    Luton, UK
    Posts
    178
    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
    Regards
    BrianB
    -------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width