+ Reply to Thread
Results 1 to 3 of 3

Vlookup in Userform Text Box

  1. #1
    Registered User
    Join Date
    04-27-2012
    Location
    New York, USA
    MS-Off Ver
    Excel 2010
    Posts
    63

    Vlookup in Userform Text Box

    I need help!
    I am new to VBA and I have created a userform with a listbox populated with Vendor names and I have a text box that I would like to use Vlookup to populate with the name of the person who approves invoices based on the Vendor name. Is this possible?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Vlookup in Userform Text Box

    Hello cschoyer,

    Welcome to the Forum!

    For best results and quickest turnaround, you should post your workbook.

    To Attach a File:

    1. Scroll down to the window below your post Additional Options
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor wallyeye's Avatar
    Join Date
    05-06-2011
    Location
    Arizona
    MS-Off Ver
    Office 2010, 2007
    Posts
    308

    Re: Vlookup in Userform Text Box

    You can use the .ListIndex and .List(#) properties to determine what was selected in the list:

    debug.print lstAll.ListIndex, lstAll.List(lstAll.ListIndex)

    where lstAll is the name of your list control.

    You would use the lstAll.List(lstAll.ListIndex) in your vlookup to return the approver:

    strApprover = worksheetfunction.vlookup(lstall.List(lstAll.ListIndex), thisworkbook.names("VendorApprovers").referstorange,2,false)

    Where VendorApprovers is a named range containing a list of all your vendors and their associated approvers.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1