Solved

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

Posted on 2015-02-10
5
61 Views
Last Modified: 2015-02-10
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
0
Comment
Question by:bjfulkerson
  • 3
  • 2
5 Comments
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40601094
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
 

Author Comment

by:bjfulkerson
ID: 40601116
Click event for Combo Box 1?
0
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40601214
Yes.

If that doesn't work then please attach your workbook, or an obfuscated one if the data is sensitive.
0
 

Author Closing Comment

by:bjfulkerson
ID: 40601398
Martin,
You have been very helpful!

Cheers,
Jody
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40601413
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

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel change font color in formula 19 28
Turn date into age 17 32
Highlight changing numbers in column 3 18
Excel 2007 VB Code for GCF 7 13
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question