View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] nile_hef@yahoo.com is offline
external usenet poster
 
Posts: 1
Default 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