E Ed Feb 11, 2004 #1 How can I fill a ComboBox with two items, say "X" and "Y", using VBA? All help is appreciated
U Ulrik Gustafsson Feb 11, 2004 #3 Hi, Add a userform in the VBA Editor called UserForm1 On that userfom add a combo box called ComboBox1 Write this code in the userform:s Initialize event: Private Sub UserForm_Initialize() With ComboBox1 .AddItem "X" .AddItem "Y" ' Set default text. .Text = "X" End With End Sub Add a module and write this code in the module in order to show the userform. Sub TestForm() UserForm1.Show End Sub HTH /Ulrik ..
Hi, Add a userform in the VBA Editor called UserForm1 On that userfom add a combo box called ComboBox1 Write this code in the userform:s Initialize event: Private Sub UserForm_Initialize() With ComboBox1 .AddItem "X" .AddItem "Y" ' Set default text. .Text = "X" End With End Sub Add a module and write this code in the module in order to show the userform. Sub TestForm() UserForm1.Show End Sub HTH /Ulrik ..
B Beto Feb 11, 2004 #4 Ed said: How can I fill a ComboBox with two items, say "X" and "Y", using VBA? Click to expand... If you want it at the initialization, you need to use the Initialize event: Private Sub UserForm_Initialize() ComboBox1.AddItem "X" ComboBox1.AddItem "Y" End Sub But in general: ComboBox1.AddItem "X" Regards,
Ed said: How can I fill a ComboBox with two items, say "X" and "Y", using VBA? Click to expand... If you want it at the initialization, you need to use the Initialize event: Private Sub UserForm_Initialize() ComboBox1.AddItem "X" ComboBox1.AddItem "Y" End Sub But in general: ComboBox1.AddItem "X" Regards,