![]() |
Filling a Combo Box with VBA
How can I fill a ComboBox with two items, say "X"
and "Y", using VBA? All help is appreciated |
Filling a Combo Box with VBA
|
Filling a Combo Box with VBA
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 .. "Ed" skrev i meddelandet ... How can I fill a ComboBox with two items, say "X" and "Y", using VBA? All help is appreciated |
Filling a Combo Box with VBA
Ed wrote:
How can I fill a ComboBox with two items, say "X" and "Y", using VBA? 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, -- Beto Reply: Erase between the dot (inclusive) and the @. Responder: Borra la frase obvia y el punto previo. |
All times are GMT +1. The time now is 04:50 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com