Retroshift
Board Regular
- Joined
- Sep 20, 2016
- Messages
- 119
- Office Version
- 2019
- Platform
- Windows
Hi, I have a search button in a userform to highlight/select the matching list item based on the value entered in an inputbox that is activated by this search button. I would like to be able to select the list item, regardless of case sensitivity. With the code below my entered value does not match if the list item contains upper case characters. How can I ignore case sensitivity in the search?
It should also recognize the list item if only a partially matching string has been entered (let's say a partial string of 3 characters).
The search criteria are the following: no blank entry field, the entry contains 3 dots/periods (to match the address format), the entry should end with "@xel.mail.com". Could these criteria be integrated in the error message below?
It should also recognize the list item if only a partially matching string has been entered (let's say a partial string of 3 characters).
The search criteria are the following: no blank entry field, the entry contains 3 dots/periods (to match the address format), the entry should end with "@xel.mail.com". Could these criteria be integrated in the error message below?
VBA Code:
Private Sub CBSearchRecipient_Click()
Dim strInput10 As String
strInput10 = Trim(InputBox("Type the e-mail address of recipient you want to find.", "SEARCH RECIPIENT ADDRESS")) 'trim to avoid starting spaces in entry
With Me.lbxRecipients
For i = 0 To .ListCount - 1
If .List(1) = LCase(strInput10)
.Selected(i) = True
Exit For
End If
Next
End With
If strInput10 = "" Then 'add the two additional criteria of 'entry format contains 3 dots, and entry should end with "@xel.mail.com"'
MsgBox "Please enter a valid e-mail address.", vbExclamation, "INVALID ENTRY"
End If
End Sub