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
- 29416 reads
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago