View Single Post
  #6   Report Post  
Chip Pearson
 
Posts: n/a
Default

The Click event in your code will run only when the list box is
clicked. The list will be populated at that time. In the code
that dominicb wrote, the list box will be populated when the
userform is initialized, generally when it is shown. Use his code
rather that yours.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Marcia3641" wrote in
message
...
Thanks Bob and dominicb. Here is what I have:
Private Sub ListBoxAgeGrp_Click()
.AddItem "Under 25"
.AddItem "26 - 34"
.AddItem "35 - 42"
.AddItem "43 - 55"
.AddItem "56 - 62"
.AddItems "63 and over"
End With
End Sub
Does it make a difference that mine says "click" instead of
"initialize"?
Also, how do I check and see if it worked. I tried going to run
usferform but
it didn't show the list that I created. Boy this is hard stuff!
--
Marcia3641


"dominicb" wrote:


Good evening Marcia3641

You need to put some code such as this behind the userform:

Private Sub UserForm_Initialize()
With ListBox1
.AddItem "Item 1"
.AddItem "Item 2"
.AddItem "Item 3"
.AddItem "Item 4"
End With
End Sub

This code assumes that your listbox is called ListBox1.

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile:
http://www.excelforum.com/member.php...o&userid=18932
View this thread:
http://www.excelforum.com/showthread...hreadid=388914