+ Reply to Thread
Results 1 to 7 of 7

multiple criteria vlookup in vba userform

  1. #1
    Forum Contributor
    Join Date
    10-17-2008
    Location
    Vancouver
    MS-Off Ver
    2002 and XP
    Posts
    117

    multiple criteria vlookup in vba userform

    Hello all,

    I have a problem with vlookup, some of the items in the lookup array are not unique and vlookup gets confused with multiple matches,

    however if I can use a combination of 1st and second columns as the criterion then it would result in a unique match.

    Problem is I don't know how to acheive this in vba (but I can with the worksheet formulas).

    Any advice? (attached is a sample worksheet)
    Attached Files Attached Files
    Last edited by kuraitori; 07-09-2009 at 01:19 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: multiple criteria vlookup in vba userform

    Hi

    Using your example file, try

    Please Login or Register  to view this content.
    rylo

  3. #3
    Forum Contributor
    Join Date
    10-17-2008
    Location
    Vancouver
    MS-Off Ver
    2002 and XP
    Posts
    117

    Re: multiple criteria vlookup in vba userform

    works wonderfully. thank you so much

  4. #4
    Forum Contributor
    Join Date
    10-17-2008
    Location
    Vancouver
    MS-Off Ver
    2002 and XP
    Posts
    117

    Re: multiple criteria vlookup in vba userform

    Okay, had trouble with this when both criteria were strings.

    altered line to the below solution and worked fine

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    (note extra quotation marks around code)

    so full solution is
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-17-2008
    Location
    Vancouver
    MS-Off Ver
    2002 and XP
    Posts
    117

    Re: multiple criteria vlookup in vba userform

    Okay, question. How do I use this if the list is on a different sheet than the active one?

    (it doesn't like the Worksheet("List").Range("A:A") stuff

  6. #6
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: multiple criteria vlookup in vba userform

    Hi

    The function is based on the format that is used in the spreadsheet, not in VBA. So things like workbooks("").sheets("") approach is not valid. It would be something like

    Please Login or Register  to view this content.
    rylo

  7. #7
    Registered User
    Join Date
    01-15-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: multiple criteria vlookup in vba userform

    Hi,
    I am unable to execute the code, where I have dates in column D3 onwards, account numbers in column G3 onwards, and the balance in column S3 onwards, I did exactly as said but it is throwing error while displaying. the date is in dd-mmm-yyyy format
    balance.Value = Cells(datarow, 19).Value
    please help

+ 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