We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Vlookup within an If statement Excel

Medium Priority
647 Views
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.

Regards

John,
Comment
Watch Question

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

=IF(AND(A1=Sheet2!A1,Sheet1!C1=Sheet2!D1),Sheet2!Z1,"")

Commented:
Here is an example I created in a file:
Book1.xls
CERTIFIED EXPERT
Most Valuable Expert 2013
Commented:
In sheet 1 D2 try this formula copied down
=LOOKUP(2,1/((A2=sheet2!A$2:A$100)*(C2=sheet2!D$2:D$100)),sheet2!Z$2:Z$100)
see attached
extend ranges as necessary
reagrds, barry

double-lookup.xls

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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.
CERTIFIED EXPERT
Most Valuable Expert 2013

Commented:
"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

Commented:
Sorry missed that in the code.

Sorted great.

Thanks for this barry,

you get the points.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.