Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi everyone, My main question is: how do I populate a combobox located in a userfor with items from an array? I thought I would use .AddItem like I would listbox, but it simply will not populate. Here is the code: Code ------------------- Private Sub ComboBox1_Change() Dim MyArray As Variant Dim Ctr As Integer MyArray = Array("Item1", "Item2", "Item3", "Item4", "Item5") For Ctr = LBound(MyArray) To UBound(MyArray) SampleReport.ComboBox1.AddItem MyArray(Ctr) Next Ctr End Su ------------------- Any advice? Thanks in advance. -- Isaa -- I Maycott ----------------------------------------------------------------------- I Maycotte's Profile: http://www.excelforum.com/member.php...fo&userid=3560 View this thread: http://www.excelforum.com/showthread.php?threadid=55606 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Currently, you're trying to add items to a combobox under a change event. The combobox will populate if you enter a value in or somehow change the text/value shown in a combobox. I think you're looking for something that will load the combobox on start, in which case put the code under a userform_initialize event. Something like this: Private Sub UserForm_Initialize() Dim MyArray As Variant Dim Ctr As Integer MyArray = Array("Item1", "Item2", "Item3", "Item4", "Item5") For Ctr = LBound(MyArray) To UBound(MyArray) ComboBox1.AddItem MyArray(Ctr) Next Ctr End Sub -- kev_06 ------------------------------------------------------------------------ kev_06's Profile: http://www.excelforum.com/member.php...o&userid=35046 View this thread: http://www.excelforum.com/showthread...hreadid=556065 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thanks a whole lot Kev. I appreciate it. -- I Maycotte ------------------------------------------------------------------------ I Maycotte's Profile: http://www.excelforum.com/member.php...o&userid=35604 View this thread: http://www.excelforum.com/showthread...hreadid=556065 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Populating Userform ComboBox with worksheet names in XL2003 | Excel Programming | |||
ComboBox populating problem | Excel Programming | |||
Populating a ComboBox | Excel Programming | |||
Populating ComboBox Methods | Excel Programming | |||
populating a combobox on a worksheet | Excel Programming |