Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ed ed is offline
external usenet poster
 
Posts: 59
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Filling a Combo Box with VBA

ComboBox1.additem "X"
ComboBox1.additem "Y

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default 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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
filling combo boxes from single outer source alekm Excel Discussion (Misc queries) 1 February 17th 06 01:49 PM
filling information from one cell and filling another. Dianne Excel Worksheet Functions 1 August 15th 05 08:14 PM
filling combo box Mike[_40_] Excel Programming 7 January 25th 04 07:42 PM
Filling a combo box from another workbook John Excel Programming 4 November 20th 03 05:59 PM
Filling multiple cells based on 1 combo box selection Serrena Carter Excel Programming 1 August 30th 03 02:14 PM


All times are GMT +1. The time now is 06:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"