+ Reply to Thread
Results 1 to 3 of 3

Multiple Criteria Lookup in VBA

  1. #1
    Registered User
    Join Date
    08-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Multiple Criteria Lookup in VBA

    I want to return the value in column C based on two user-defined fields that will be contained in column A and column B. For example, for company1 and field3 I want to return '54' and for 'company3' and 'field5' I want to return 'Pig'. The Excel data layout is shown in the attachment. I am happy to hard code the two search criteria (Company and Field).

    Once that is sorted I would to map the value to pre-defined bookmarks in Word. The bookmarks match the names found in column B.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Multiple Criteria Lookup in VBA

    A simple worksheet formula will do this.

    If you enter a company choice in E2, and field choice in F2, then this formula in G2:

    =INDEX($C$2:$C$16, MATCH(E2&F2, INDEX($A$2:$A$16 & $B$2:$B$16, 0), 0))
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Multiple Criteria Lookup in VBA

    I'm afraid that doesn't work. I am working in VBA in a Word document. I need to use VBA to perform the multi-criteria lookup into Excel. It is just the lookup code I need now.

+ 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