+ Reply to Thread
Results 1 to 2 of 2

Options and Combo Boxes

  1. #1
    mtm4300
    Guest

    Options and Combo Boxes

    I have two options in my data sheet. When the first option is clicked on, I
    want a combobox to appear. When the second option is clicked on, I want a
    different combobox to appear in the same location as the first. I am having
    trouble writing the code for this. I would greatly appreciate it if someone
    could help me with this.

  2. #2

    Re: Options and Combo Boxes

    Think laterally: use the same combo box but repopulate it when the
    option is clicked.

    mtm4300 wrote:
    > When the second option is clicked on, I want a different
    > combobox to appear in the same location as the first.


    You can populate a combo box by setting it's .List property to an array
    variable (or it's .Column property, if the array is
    inconveniently-directed)

    Private Sub optFoo_Click()

    Dim arrList as Variant
    Dim iRow as Integer

    If Me.optFoo.Value=True Then
    'Code to redimension and populate an array from source 1
    arrList = ThisWorkbook.Names!myName.RefersToRange.Value
    Else
    'Code to redimension and populate an array from source 2
    Redim arrList(0 to 6, 0 to 1) ' List property is a zero-based array
    For iRow = 0 to 6
    arrList(irow, 0) = Chr(64+ iRow)
    arrList(irow, 1) = iRow
    Next iRow
    Else

    Me.cboFoo2.Clear
    Me.cboFoo2.List = arrList

    Erase arrList

    End If


+ 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