Solved

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

Posted on 2015-02-10
5
62 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 47

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 47

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 47

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

713 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