Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing a Combo box before adding to it???? 1

Status
Not open for further replies.

ribhead

Technical User
Jun 2, 2003
384
US
I have a combo box that I added to a sheet and All I'm trying to do is clear it (empty it) before I add to it so I don't get duplicate data. There must be an easy way to do this because the way I'm doing it seems a bit verbose.

Here is my code any thoughts?

Option Explicit
Sub ClearMe()
Dim r As Long
With Sheet1.cbpartnumber
.ListFillRange = Range("AZ1").Address
End With
On Error Resume Next
Do While Sheet1.cbdestination.ListCount <> 0
For r = 0 To Sheet1.cbdestination.ListCount
With Sheet1.cbdestination
.RemoveItem (r)
End With
Next r
Loop
End Sub

Thanks, Rib

Bartender:Hey aren't you that rope I threw out an hour ago?

Rope:No, I'm a frayed knot.
 
Something like this ?
With Sheet1.cbdestination
If .ListCount > 0 Then
.ListFillRange = "A1"
.ListIndex = -1
.ListFillRange = ""
End If
End With

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top