Select ListBox entries

Takes a comma-separated list and selects matching entries of a ListBox.

Private Sub MarkMe(List As ListBox, Items As TextBox)
  Dim MergedData As Variant
  Dim iArray As Variant
 
  If (Not IsNull(Items.Value)) Then MergedData = Items.Value
 
  iArray = Split(MergedData, ",", -1, vbTextCompare)
 
  ' set everything to false (deselect all)
  For intI = 0 To List.ListCount
    List.Selected(intI) = False
  Next intI
 
  For Each curItem In iArray
    curItem = Trim(curItem)
    For intI = 0 To List.ListCount
      If List.ItemData(intI) = curItem Then
        List.Selected(intI) = True
        Exit For
      End If
    Next intI
  Next curItem
End Sub