+ Reply to Thread
Results 1 to 5 of 5

VBA Userform Vlookup

  1. #1
    Registered User
    Join Date
    02-21-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    72

    VBA Userform Vlookup

    Hi,

    I'm trying to build a userform in excel which has several inputs. The Product input is a drop down with the selections shown.

    If a user selects ProductA and enters a price of $10, the Quantity field should lookup up the ProductA table and return a value of 5 for the Qty. Similarly, if the user select ProductC and enters a price of 50, the Qty should be 2. I want the Quantity field to update once the Product or Price field have been changed. I've attached an example of the workbook and the code I'm working on.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: VBA Userform Vlookup

    Hi anthony_91, here is one way (add this to the Userform1 code):

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-21-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    72

    Re: VBA Userform Vlookup

    Thanks Berlan. It works, although is there any way of doing this with Vlookups?

  4. #4
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: VBA Userform Vlookup

    I'm afraid i couldn't find a match with vlookup via VBA at my first try, not really sure why (without looking into it in greater detail), but I the alternative I provided should do the trick nevertheless.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Depending on how you've populated the combobox it might be possible to use it's ListIndex to find the relevant row.
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Vlookup in userform
    By cdowney in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-02-2013, 06:50 PM
  2. VLOOKUP in userform
    By Hond70 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-25-2011, 07:32 AM
  3. VLookup In UserForm
    By shudder in forum Excel General
    Replies: 3
    Last Post: 12-12-2009, 09:24 PM
  4. Using VLOOKUP In A UserForm
    By SamuelT in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2008, 07:42 AM
  5. [SOLVED] Vlookup in a userform
    By R D S in forum Excel General
    Replies: 6
    Last Post: 01-26-2005, 06:06 PM

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