VBA/Excel/Access/Word/Excel/ComboBox

Материал из VB Эксперт
Перейти к: навигация, поиск

Does ComboBox contain data

 
     Private Sub ComboBox2_Click()
           If ComboBox1.Value="" Then Exit Sub
     End Sub



Fill data to ComboBox

 
     Private Sub Workbook_Open()
         Dim vMonths As Variant
         Dim vYears As Variant
         Dim i As Integer
         "Create date arrays
         vMonths = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", _
                        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
         vYears = Array(2006, 2007)
         "Populate months using AddItem method
         For i = LBound(vMonths) To UBound(vMonths)
             Sheet1.ruboBox1.AddItem vMonths(i)
         Next i
         "Populate years using List property
         Sheet1.ruboBox2.List = WorksheetFunction.Transpose(vYears)
     End Sub