Combo Box + Delete Row

  • Thread starter Thread starter Cameron
  • Start date Start date
C

Cameron

Hi All,

Have created a form with a combo box and have populated the box with the
following code ...

Private Sub UserForm_Activate()
Dim cell As Range
ComboBox1.RowSource = ""
With Worksheets("Extra Tables")
For Each cell In .Range("Doctors")
If Len(Trim(cell.Text)) > 0 Then
ComboBox1.AddItem cell.Value
End If
Next
End With
End Sub

Problem I've noticed is that preliminary testing, the list keeps being added
to by the list is the Named Range "Doctors" - Very stumped on how to resolve
this.

Also, how do I go about deleting the record (rpw) from the Named Range
"Doctors" after selection??

Cheers,
Cameron
 
the code as shown should add each entry in the named range Doctors to the
list.

it is unclear what you say the problem is. If you mean the list is being
added multiple times, then perhaps you need to do this in the Initialize
event

Private sub Userform_Initialize()
 
Cameron,

in testing your code the combo box will keep populating with the list every
time you run it, try putting a clear after your dim statement;

Dim cell As Range
ComboBox1.Clear

this will empty the combobox.

David
 
Cameron,

in testing your code the combo box will keep populating with the list every
time you run it, try putting a clear after your dim statement;

Dim cell As Range
ComboBox1.Clear

this will empty the combobox.

David
 
David,

Thanks so much - didn't see that as a solution. (Still new to VBA)
Greatly apreciated - onwards and upuwards with my delete. (^5)

Cameron
 

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

Back
Top