Vlookup within an If statement Excel

Posted on 2009-02-12
Last Modified: 2012-06-21
Hi All,

Hoping one of you experts can help.

I have two excel worksheets that i need to compare data between then bring throgh one of the fields to the other sheets.  eg.

I require on sheet 1 values in A & C to check and match values A & D in Sheet 2
Sheet 1 A = Sheet 2 A
Sheet 1 C = Sheet 2 D.

If the test is correct i need the corresponding value in sheet 2 colum z to be brought to sheet 1 most likely in the form of a vlook.

hope the above is clear.


Question by:jstlawyers
    LVL 17

    Expert Comment

    Try this formula in Sheet 1 in cell D1 and copy down:

    LVL 17

    Expert Comment

    Here is an example I created in a file:
    LVL 50

    Accepted Solution

    In sheet 1 D2 try this formula copied down
    see attached
    extend ranges as necessary
    reagrds, barry


    Author Comment

    Thanks guys for the code.

    both of you are 90% their and i've done something wrong (not 100% described the requirement).
    sheet 1 and sheet 2 don't run in sequence. so

    Sheet 1  A & C values need to look through all rows in sheet 2 coloums A & D.  There will only be one row of matching data.  Sheet 1 though has additional data witch is not in sheet 2.
    LVL 50

    Expert Comment

    by:barry houdini
    "Sheet 1  A & C values need to look through all rows in sheet 2 coloums A & D.  There will only be one row of matching data.  Sheet 1 though has additional data witch is not in sheet 2."
    That's what my suggestion will do. formula in D2 will look through rows 2 to 100 in sheet2, if both values match in the same row then column Z value will be returned. If there are no matches then formula returns #N/A. You can make it return another value like "No match" if you change to this
    =IF(SUMPRODUCT((A2=Sheet2!A$2:A$100)*(C2=Sheet2!D$2:D$100)),LOOKUP(2,1/((A2=Sheet2!A$2:A$100)*(C2=Sheet2!D$2:D$100)),Sheet2!Z$2:Z$100),"No match")
    You can extend the ranges to cover as many rows as you need in sheet2

    Author Comment

    Sorry missed that in the code.

    Sorted great.

    Thanks for this barry,

    you get the points.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
    My experience with Windows 10 over a one year period and suggestions for smooth operation
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now