Fill data to ComboBox : ComboBox « Excel « VBA / Excel / Access / Word






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.ComboBox1.AddItem vMonths(i)
         Next i

         'Populate years using List property
         Sheet1.ComboBox2.List = WorksheetFunction.Transpose(vYears)
     End Sub

 








Related examples in the same category

1.Does ComboBox contain data