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
- 29443 reads
Recent comments
5 years 41 weeks ago
6 years 27 weeks ago
6 years 39 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 48 weeks ago
7 years 4 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago