Combobox exit event search error
I have a combo box on a form for requestor, when the requestor is
selected I'm auto populating the email address box with the following
code (the list of requestors preloaded into the combo box is in
[data!e10:e21] and the email addresses are one column to the right)
Private Sub RequestorCBox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim myEmail As String
Dim myRequestor As String
Call TurnOff
myRequestor = RequestorCBox.Value
If RequestorCBox.Value < "" Then
Sheets("Data").Select
Range("e11:e21").Select
Application.FindFormat.NumberFormat = "General"
Selection.Find(what:=myRequestor, after:=ActiveCell,
LookIn:=xlValues, _
lookat:=xlPart, searchorder:=xlByColumns,
searchdirection:=xlNext, _
MatchCase:=False, searchformat:=False).Activate
ActiveCell.Offset(0, 1).Select
myEmail = ActiveCell.Value
Me.EmailBox.Value = myEmail
End If
End Sub
The problem I'm running into is that the list of requestors on the data
sheet isn't (and never will be) comprehensive. So from time to time
someone will have to type in their name, when this happens, the name
isn't found in the list, so this section of code can't continue. How
do I make it move on without auto populating the email box if the name
isn't found in that range?
|