![]() |
Help with ComboBox
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 -- Trefor |
Help with ComboBox
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 "Trefor" wrote in message ... 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 -- Trefor |
Help with ComboBox
I had this code in a module, so I take it that is the problem?
How do I trap the X being hit? -- Trefor "Chip Pearson" wrote: 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 "Trefor" wrote in message ... 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 -- Trefor |
All times are GMT +1. The time now is 01:11 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com