Any ideas or info is awesome!
Fill your sample file with sample data.
i also want the box to auto update as new entrys are put into the cutlist.
You'll have to explain how the cutlist is updated. From the userform? If so, then call the paintbox1_change sub from wherever the update happens.
Just with some quick fill data, the listbox appears to work as listed.
To have a unique list, use a collection, because collections can't have duplicate data (well, keys actually). We take advantage of that by attempting to put all the data in the collection. The collection refuses to insert the duplicate data and because we have error reporting turned off, we can pass by without stopping. So we end up with a unique list.
Private Sub PaintBox_Change()
Dim rng As Range, e
Dim UNIQUE As New Collection
With Me
.PaintListBox1.Clear
If Len(.PaintBox.Value) Then
For Each e In Sheets("CutList").Cells(1).CurrentRegion.Columns(1).Offset(1).Value
If (e <> "") * (e Like "*" & .PaintBox.Value & "*") Then
On Error Resume Next
UNIQUE.Add CStr(e), CStr(e)
On Error GoTo 0
End If
Next
'Iterate the collection and stuff the listbox.
For e = 1 To UNIQUE.Count
.PaintListBox1.AddItem Unique(e)
Next
With .PaintListBox1
If .ListCount > 0 Then .ListIndex = 0
End With
End If
End With
End Sub
Bookmarks