Help with ComboBox

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
I had this code in a module, so I take it that is the problem?

How do I trap the X being hit?
 
Back
Top