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
- Login or register to post comments
- 29446 reads
Recent comments
5 years 42 weeks ago
6 years 28 weeks ago
6 years 40 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 49 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago