Check if exists in List

This utility demonstrates how you can use the match function to find a string even in a listbox or a dropdown.
Sub Check() If blnExists(Sheet1.Range("C13").Value, Sheet1.ListBoxes("List Box 1")) = True Then MsgBox "Exists" Else MsgBox "Does not exists" End If End Sub Function blnExists(strFind As String, lst As ListBox) As Boolean On Error Resume Next blnExists = (Application.WorksheetFunction.Match(strFind, lst.List, 0) > 0) If Err.Number > 0 Then blnExists = False On Error GoTo 0 End Function
| Attachment | Size |
|---|---|
| ExistsInList.xls | 27.5 KB |
»
- Vishesh's blog
- Add new comment
- 3339 reads

Recent comments
5 hours 6 min ago
8 hours 30 min ago
8 hours 53 min ago
14 hours 55 min ago
15 hours 47 min ago
1 day 6 hours ago
1 day 6 hours ago
1 day 9 hours ago
1 day 18 hours ago
2 days 13 hours ago