Help with ComboBox

G

Guest

I am trying to use a UserForm for the first time and I am having a few
problems.

I have managed to create a ComboBox and populate it. I have managed to show
and unload the UserForm, but I just can't seem to get the data selected by
the combobox.

What have I done wrong?

Sub testuform()
Dim CBSel
WRContactList.Show
Dim ctl As Control

For Each ctl In Me.Controls
If ctl.Name = "ComboBox1" Then
CBSel = ctl.Text
End If
Next ctl

MsgBox CBSel

End Sub
 
C

Chip Pearson

Where are you putting this code? If the user closes the form by
clicking the 'X' button at the top left of the form, the form is
unloaded and all its controls are cleared.


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

Guest

I had this code in a module, so I take it that is the problem?

How do I trap the X being hit?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top