+ Reply to Thread
Results 1 to 5 of 5

Using two values in VLOOKUP funcation

  1. #1
    Registered User
    Join Date
    12-07-2009
    Location
    Waterloo, Canada
    MS-Off Ver
    Excel 2007
    Posts
    2

    Using two values in VLOOKUP funcation

    Hello,

    I have a workbook with two worksheets (Sheet1 and Sheet2). Sheet1 has three columns (ID, City, Name). Sheet2 has a (ID, City, ID Code, Name, City).

    What I would like to do is use the ID, City from sheet one to look up the ID, City from sheet too to pull in the value of ID Code (should ID, City exist in Sheet2). I think the formula would look something like =IF(D2="",VLOOKUP($A2:$B2,Sheet2!$A$2:$C$2213,3,FALSE)). The thing is it just results in a 0 in the cell with the formula.

    The purpose of this is to determine whether or not values in Sheet1 appear in Sheet2.

    Can anyone help me out? I hope I have posted this message to the right forum.

    Jeff
    Attached Files Attached Files
    Last edited by jdunnett; 12-07-2009 at 10:31 PM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Using two values in VLOOKUP funcation

    Hi, could you possibly post just a small data sample? no need for half a MB to illustrate the issue. Three or four rows should do.

    thanks

  3. #3
    Registered User
    Join Date
    12-07-2009
    Location
    Waterloo, Canada
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Using two values in VLOOKUP funcation

    Quote Originally Posted by teylyn View Post
    Hi, could you possibly post just a small data sample? no need for half a MB to illustrate the issue. Three or four rows should do.

    thanks
    I have fixed the above file (with just small data sample). I am sorry for the breach of ettiquette on that one.

    Jeff

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Using two values in VLOOKUP funcation

    Try,
    =IF(COUNTIF(Sheet2!A:A,A2)=0,"Nope","")
    drag the formula down
    "Nope", will appear if there is no match

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

    Re: Using two values in VLOOKUP funcation

    You'll have to clean up your data. There are a lot of straggler "hidden spaces" after some words that will make these matches not work all the time. For instance Sheet2!B166 has the word "Montreal" and two hidden spaces, so it doesn't match the row 26 on Sheet1 like it should.

    Anyway, you'll need to clean up your data.

    Then put this formula in Sheet1!D2 and copy it down:

    =INDEX(Sheet2!$C$1:$C$2500, MATCH(A2&B2, INDEX(Sheet2!$A$1:$A$2500 & Sheet2!$B$1:$B$2500, 0), 0))

    =========
    Your large file doesn't break any rules or etiquette, it's just overkill. I'd rather see too much data than too little, or more often an example that is too "dumbed down".
    _________________
    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!)

+ 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