Need to enter 2 initials in a Combo box to populate User form

I am using this code to auto populate a user form.  I only takes one initial before it auto pops the form.  I would like to enter both as I have several employees with the same first initial

Private Sub ComboBox1_Change() 'auto pop by initials
Dim idx As Long

    idx = ComboBox1.ListIndex

    If idx <> -1 Then

        With Sheets("EmployeeName")
            TxtFname.Value = .Range("B" & idx + 2).Value 'fname
           
            TxtLName.Value = .Range("C" & idx + 2).Value 'lastname
           
            TxtStatus.Value = .Range("F" & idx + 2).Value 'status
           
            TxtHDept.Value = .Range("D" & idx + 2).Value 'HDept
           
            TxtUPH.Value = .Range("G" & idx + 2).Value 'UPH
           
      End With
       
    End If

    'new
    CB2FunctionCode.SetFocus
   
End Sub
bjfulkersonAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Martin LissConnect With a Mentor Older than dirtCommented:
Yes.

If that doesn't work then please attach your workbook, or an obfuscated one if the data is sensitive.
0
 
Martin LissOlder than dirtCommented:
Your code should be in the Click event rather than the Change event. That way it will execute when the user makes his selection.
0
 
bjfulkersonAuthor Commented:
Click event for Combo Box 1?
0
 
bjfulkersonAuthor Commented:
Martin,
You have been very helpful!

Cheers,
Jody
0
 
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.