Link to home
Start Free TrialLog in
Avatar of P3dr01980
P3dr01980

asked on

Vlookup in Excel Userform

Hi, I am trying to use a vlookup in an excel userform so that when I type a number ID in the textbox "TextBoxAgentID" another textbox "TextBoxDBA" fills up with the name. I have the Data in Sheet1 where the Agent ID is in column A:A and the Name is in Column B:B.

Can somebody please help me?? :(

Thanks!
Avatar of StellanRosengren
StellanRosengren
Flag of Sweden image

Hi
In the userform code module you can enter the code

Private Sub TextBoxAgentID_Change()
    On Error Resume Next
    Me.TextBoxDBA.Value = Application.WorksheetFunction.VLookup( _
        CInt(Me.TextBoxAgentID.Value), ThisWorkbook.Sheets(1).UsedRange, 2, False)    
End Sub

which works if the AgentID is an integer.
ASKER CERTIFIED SOLUTION
Avatar of raja_ind82
raja_ind82
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial