Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

vlookup combined ifand formula

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Vlookup Combined with If/And Formula

Vlookup Combined with If/And Formula

ResolvedVersion 2010

Adrian has attended:
Excel VBA Introduction course
Excel VBA Intermediate course
Excel Intermediate course

Vlookup Combined with If/And Formula

Hi

I am struggling to return a specific result when using a vlookup which needs to be combined with an If/And formula. Also, there might be multiple potential results but with all, some, none matching. Example is below:

Col A Col B Col C Col D
Product Code Sale Start Date Sale End Date
apple AB2 03/02/2016 03/02/2016
orange AB3 03/02/2016 03/02/2016
pear CD1 03/02/2016 03/02/2016
orange CD4 01/03/2016 31/03/2016
orange CD3 01/03/2016 31/03/2016
pear CD8 01/03/2016 01/03/2016
apple CD22 01/03/2016 01/03/2016

In lets say Cell E1 contains Orange, E2 contains 01/03/2016 and E3 contains 31/03/2016. I need the formula to look up E1 within the table and if it finds E1 (ie Orange), then to see if E2 & E3 match Columns C & D respectively, and if so then return the associated code in Col B. As you can see, there could be multiple answers in which case it needs to just pick 1 code (doesn't matter which).

I thought the best would be a vlookup, then IF combined with AND statements to see if the dates match, and return Code if so. I am struggling to combine this, are you able to help please?

Thank you

RE: Vlookup Combined with If/And Formula

A follow up, would it be easier with VBA and if so how could I achieve this?

RE: Vlookup Combined with If/And Formula

Hi Adrian,

Thank you for the forum question and I am sorry about the late respond.

What you need is an array function.

All formulas and function can be turned into an array function if you need to work with arrays instead of single cells.

If you have your data as described in your question type:


=INDEX($B$2:$B$8,MATCH(E1&F1&G1,$A$2:$A$8&$C$2:$C$8&$D$2:$D$8,0))

To changed the formulas to array formulas do not press ENTER when you have typed the formulas. You must press CTRL SHIFT ENTER.

In the formula bar you will now see:

{=INDEX($B$2:$B$8,MATCH(E1&F1&G1,$A$2:$A$8&$C$2:$C$8&$D$2:$D$8,0))}

The {} brackets will always need to be around array formulas. You cannot just type them. You must press CTRL SHIFT ENTER.

The array formulas are also called CSE formulas.

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Fri 12 Feb 2016: Automatically marked as resolved.

Excel tip:

Deleting cells, Rows & columns

place your cursor on a cell, row number or column letter and use CTRL + -.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.11 secs.