Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Populating a ComboBox in a UserForm


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Populating a ComboBox in a UserForm


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Populating a ComboBox in a UserForm


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
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
Populating Userform ComboBox with worksheet names in XL2003 MAWII Excel Programming 0 August 9th 05 09:07 PM
ComboBox populating problem Werner[_33_] Excel Programming 1 July 29th 05 10:00 PM
Populating a ComboBox DirInfo Excel Programming 1 March 17th 05 10:03 PM
Populating ComboBox Methods Todd Huttenstine[_2_] Excel Programming 8 January 19th 04 12:14 AM
populating a combobox on a worksheet Tim Marsh[_2_] Excel Programming 2 November 3rd 03 12:44 PM


All times are GMT +1. The time now is 11:55 PM.

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"