+ Reply to Thread
Results 1 to 9 of 9

Reusing a list of options on a form

Hybrid View

  1. #1
    Registered User
    Join Date
    01-13-2007
    Posts
    13

    Reusing a list of options on a form

    Hello

    I have a list of options:

    Daily, Weekly, Monthly, Never

    I am looking to create 9 questions all of which use a combo box to generate the answer
    The answer comes from the list above

    How do I reuse this without have to do something like this for every question:

    With cmbQuestion1
    .AddItem "Daily"
    .AddItem "Weekly"
    .AddItem "Monthly"
    .AddItem "Never"
    End With

    Thanks

  2. #2
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    Two ways:

    1. put the selections in some cells somewhere (could be a hidden sheet) and use this range of cells as the "ListFillRange" for each combo box

    2. do the .AddItem thing for the first combo box, then use something like

    cmbQuestion2.List = cmbQuestion1.List

  3. #3
    Registered User
    Join Date
    01-13-2007
    Posts
    13
    Thanks for the tips
    Both work

  4. #4
    Registered User
    Join Date
    01-13-2007
    Posts
    13
    Hello

    How does ListFillRange work

    I have:

    With cmbDivision
    ControlFormat.ListFillRange = Worksheets("ListData").Range("A2:A12")
    End With

    The key dats is in A2:a12 on the ListData worksheet
    This returns an error

  5. #5
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    a couple of changes.

    First, where is the code? And, what is the name of the combo box? (cannot tell from the code you posted if cmbDivision is a variable or the name of the box)

    If the code is on the window of the sheet that contains the combo box, then the code would be:
    With Me.cmbDivision
        .ListFillRange = "ListData!A2:A15"
    End With
    Note that the ListFillRange is a String, not a Range.

    If the code is in a module, and you use the Object name for the Worksheet containing the combo box, and the Object name of that worksheet (NOT the name on the tab) is Sheet1 then the code is:
    With Sheet1.cmbDivision
        .ListFillRange = "ListData!A2:A15"
    End With
    If you are using the name on the tab of the worksheet, then it would have to be something like this:
    With Sheets("mySheet").OLEObjects("cmbDivision")
        .ListFillRange = "ListData!A2:A15"
    End With

  6. #6
    Registered User
    Join Date
    01-13-2007
    Posts
    13
    Hi

    Option 3 looks like the best option as it is working from a named worksheet (ListData)
    It comes back with 'Run-Time Error 1004' - 'Unable to get the OLEObjects property of the worksheet class'
    I have looked in a number of places including the MS site and can't seem to resolve this
    Do you have any thoughts?
    Code attached - note your version is currently commented (See UserForm_Initialize - See here section)

    Thanks
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1