Anda di halaman 1dari 83

THE MISSING EXCEL® USER

GUIDE TO LOOK UP
DATA FROM LISTS
USING FORMULAS
VOLUME 1

by John Franco

Founder Excel-Spreadsheet-Authors.com

Find a Needle in the haystack like an Excel Veteran


The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Brief TOC
Brief TOC ....................................................................................... 2

About John ..................................................................................... 5

Detailed TOC .................................................................................. 7

Introduction ................................................................................. 10

What’s in it for Me?........................................................................ 12

How to get the Most of this eBook ................................................... 14

Lookup/Search/Fetching Principles for Unique Match........................... 18

1. LOOK UP a Number/Date/Text Equal to… ..................................... 19

2. LOOK UP a Text that Begins with/Ends with/ Contains… ................. 30

3. LOOK UP a Text Case-Sensitive .................................................. 39

4. LOOK UP Two Index Columns and other Advanced LOOKUP Formulas


43

5. LOOK UP the Number/Date/Text that is the Max/Min, newest/Oldest,


A/Z 58

6. LOOK UP the Exact or Lower Approximate Text/Number/Date......... 62

7. LOOK UP the Exact or Lower/Greater Approximate Text/Number/Date


72

Table_array Troubleshooting ........................................................... 75

FAQ............................................................................................. 76

LOOKUP Resources ........................................................................ 78

Excel Resources ............................................................................ 79

What Readers Say about Excel-Spreadsheet-Authors.com… ................. 80

Get New eBooks at ESA Store ......................................................... 82

Excel-Spreadsheet-Authors.com 2 | Page
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

THE MISSING EXCEL USER ®

GUIDE TO LOOK UP
DATA FROM LISTS
USING FORMULAS
VOLUME 1

by John Franco

Excel-Spreadsheet-Authors.com 3 | Page
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

The Missing Excel® User Guide to Look Up Data from Lists Using
Formulas Volume 1

by John Franco

© 2009 by Excel-Spreadsheet-Authors.com

Notice of Rights

All rights reserved. No part of this book may be reproduced, stored in a


retrieval system, or transmitted in any form or by any means, without the
prior written permission of the publisher.

If you want to sell this book, use it for commercial purposes or distribute
it in bulk quantities in your workplace, please Contact me

Notice of Liability

The author and publisher have made every effort to ensure the accuracy
of the information herein. However, the information contained in this book
is sold without warranty, either express or implied. Neither the authors
and Excel-Spreadsheet-Authors.com, nor its dealers or distributors, will
be held liable for any damages to be caused either directly or indirectly by
the instructions contained in this book, or by the software or hardware
products described herein.

Trademark Notice

Rather than indicating every occurrence of a trademarked name as such,


this book uses the names only in an editorial fashion and to the benefit of
the trademark owner with no intention of infringement of the trademark.

Excel-Spreadsheet-Authors.com 4 | Page
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

About John
John Franco is native of Ecuador, he is a Civil Engineer
and a Bachelor in Applied Linguistics with focus on creating
systems for work, his long term objective in life is helping
others to put their ideas into world.

His first entrepreneurial initiative is the web site


www.Excel-Spreadsheet-Authors.com; which is dedicated
to Mid/Advanced Excel users so they can polish their skills to reach higher
productivity and clarity.

He quitted his job after having worked 7 years for Norberto Odebrecht
Construction Company (ranked among the World’s Top 50 Largest
Construction Contracting Firms according to Engineering News Record
2008).

Email him at: john@excel-spreadsheet-authors.com

"Follow your passion, and success will follow you." - Arthur Buddhold

Are you passionate about Excel or any other given field? Turn your skills
into a profitable online business. You need your Brain, Motivation and the
right tools.
SBI is the Tool I Love

Subscribe to Excel-Spreadsheet-Authors.com updates: RSS


feed in a reader or RSS by email

Expand any Excel topic by discussing it at the LinkedIn Group.


Join us here: Excel Spreadsheet Authors Group

Excel-Spreadsheet-Authors.com 5 | Page
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

To Anita, Mateo and Maria Pia.

You inspire me in unimaginable ways.

This first work belongs to you.

Excel-Spreadsheet-Authors.com 6 | Page
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Detailed TOC
Brief TOC ....................................................................................... 2

About John ..................................................................................... 5

Detailed TOC .................................................................................. 7

Introduction ................................................................................. 10

What’s in it for Me?........................................................................ 12

How to get the Most of this eBook ................................................... 14

VLOOKP 0.................................................................................. 15

VLOOKUP 1................................................................................ 15

INDEX and MATCH ...................................................................... 15

Array Formulas .......................................................................... 16

SUMPRODUCT ............................................................................ 16

Lookup/Search/Fetching Principles for Unique Match........................... 18

1. LOOK UP a Number/Date/Text Equal to… ..................................... 19

1.1. Example 1 – LOOK UP a text .............................................. 20

1.2. Example 2 – LOOK UP a Date ............................................. 22

1.3. Main Limitations/Problems with VLOOKUP Exact Match ........... 24

1.4. Example 3 - LOOK UP a Text that is not Located in a Left Index


Column ..................................................................................... 25

1.5. Example 4 - LOOK UP a Date that is not Located in a Left Index


Column ..................................................................................... 27

1.6. Build a Strong VLOOKUP Exact Match with this Checklist......... 29

2. LOOK UP a Text that Begins with/Ends with/ Contains… ................. 30

2.1. Example 1 – LOOK UP a Text that Contains “” ....................... 32

2.2. Example 2 – LOOK UP a Text that Begins with “” ................... 34

2.3. Example 3 – LOOK UP a text that Ends with “” ...................... 35

Excel-Spreadsheet-Authors.com 7 | Page
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

2.4. Example 4 – LOOK UP a Text that Contains “” and is not Located


in a Left Index Column ................................................................ 36

2.5. Example 5 – LOOK UP a Text that Begins with “” and is not


Located in a Left Index Column .................................................... 37

2.6. Example 6 – LOOK UP a Text that Ends with “” and is not


Located in a Left Index Column .................................................... 38

3. LOOK UP a Text Case-Sensitive .................................................. 39

3.1. Example 1 – LOOK UP a Case Sensitive Text Using an Array


Formula .................................................................................... 40

3.2. Example 2 – LOOK UP a Case Sensitive Text Using SUMPRODUCT


42

4. LOOK UP Two Index Columns and other Advanced LOOKUP Formulas


43

4.1. Example 1 – LOOK UP a Text and a Number Located in Two


Index Columns Using a Helper Column .......................................... 45

4.2. Example 2 – LOOK UP a Text and a Number Located in Two


Index Columns Using SUMPRODUCT .............................................. 46

4.3. Example 3 – LOOK UP a Text and a Number in Two Index


Columns Using an Array Formula .................................................. 47

4.4. Example 4 – LOOK UP a Month Using a Helper Column ........... 48

4.5. Example 5 – LOOK UP a Month Using SUMPRODUCT .............. 49

4.6. Example 6 – LOOK UP a Month Using an Array Formula .......... 50

4.7. Example 7 – LOOK UP a Number with Decimal Places ............. 51

4.8. Example 8 – LOOK UP the Last Instance of a Value ................ 53

4.9. Example 9 – LOOK UP the Most Frequent Value ..................... 54

4.10. Example 10 – LOOK UP a Value Based on Index Column and


Index Row ................................................................................. 55

4.11. Example 11 – LOOK UP in Reverse Mode .............................. 56

4.12. Example 12 – LOOK UP Multiple Index Column Criteria ........... 57

Excel-Spreadsheet-Authors.com 8 | Page
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

5. LOOK UP the Number/Date/Text that is the Max/Min, newest/Oldest,


A/Z 58

5.1. Example 1 – LOOK UP the Biggest Quantity .......................... 59

5.2. Example 2 – LOOK UP the Newest Date-Time ........................ 60

6. LOOK UP the Exact or Lower Approximate Text/Number/Date......... 62

6.1. Example 1 – LOOK UP an Exact or Approximate Number (case 1)


64

6.2. Example 2 – LOOK UP an Exact or Approximate Text ............. 65

6.3. Example 3 – LOOK UP an Exact or Approximate Number (case 2)


66

6.4. Example 4 – LOOK UP an Exact or Approximate Date/Time ..... 67

6.5. Example 5 – LOOK UP Exact or Approximate Percentages ....... 68

6.6. Main Limitations/Problems with VLOOKUP Approximate Match . 70

6.7. Build a Strong VLOOKUP Approximate Match with this Checklist…


71

7. LOOK UP the Exact or Lower/Greater Approximate Text/Number/Date


72

7.1. Example 1 - LOOK UP an Exact or Lower/Greater Approximate


Number..................................................................................... 74

Table_array Troubleshooting ........................................................... 75

FAQ............................................................................................. 76

LOOKUP Resources ........................................................................ 78

Excel Resources ............................................................................ 79

What Readers Say about Excel-Spreadsheet-Authors.com… ................. 80

Get New eBooks at ESA Store ......................................................... 82

Excel-Spreadsheet-Authors.com 9 | Page
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Introduction
Was One of your Well-Done-Job-Recognitions Related to some
Excel Spreadsheet Work?

“There have been too many to list, but the most


common one is something so simple, which for some
reason people can't grasp, vlookup. I can't tell you how
many times I have been called to save the day,
because someone needed to merge data, using a
vlookup.
Data resides in other tables in a particular order and in variable
quantities, on the other side, that is at the front end you need
particular attributes of given text/dates/numbers.”

Richard Kline
Financial Services Professional
Greater New York City Area

The fact is that most of your data resides in tables; you need to pick
specific items based on some index column that is continually updated at
the backend.
Let me ask you a few questions…
 Want to fill tables with data of other tables?
 Want to gather information of different tables?
 Want to compare tables?
 Want to embed a value from a table in a formula?
 Want to communicate information of any given item from a table?
 Want to analyze information from any given value from a table?
In summary, searching unique items (needles) in lists (haystacks) is a
common task you face, not only to communicate the found value to
others but to use it as part of your analysis by using the value or
embedding it into a formula.
Well, you got the point; LOOKING UP data is an essential task. Despite its
frequency and relevancy for your job, LOOKUP formulas are one of the
main headaches of Excel Users. Why does this happen?
It is not as simple as the formulas appear to be, you need to take into
consideration a lot of Frontend and Backend issues.

Excel-Spreadsheet-Authors.com 10 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

The main purpose of this book is contributing to develop a strong


awareness about LOOKUP formulas: VLOOKUP, INDEX and MATCH, Array
Formulas, SUMPRODUCT, etc and to be a good reference in moments of
LOOKUP urgencies.

John Franco

Founder www.Excel-Spreadsheet-Authors.com

Excel-Spreadsheet-Authors.com 11 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

What’s in it for Me?


It is no exaggeration that knowing excel formulas can
give you a career boost. From someone starting at the
long list of numbers, you can become a data god who
can lookup, manipulate and analyze any spreadsheet by
learning few excel formulas.

Chandoo, Pointy Haired Dilbert

Chandoo.org

Here’s what you will find in this book…


 LOOK UP data from Lists (vertical tables). Lists with column
headings going on top and registers going down as in a typical
database.
 Learn how to build LOOKUP formulas that retrieve a single value.
The single value may be a result of a single or multiple index
column criteria
 Find examples for 7 LOOKUP formulas cases/categories:

1. LOOK UP a Number/Date/Text Equal to…


2. LOOK UP a Text that Begins with/Ends with/ Contains…
3. LOOK UP a Text Case-Sensitive
4. LOOK UP Two Index Columns and other Advanced LOOKUP
Formulas
5. LOOK UP the Number/Date/Text that is the Max/Min,
newest/Oldest, A/Z
6. LOOK UP the Exact or Lower Approximate Text/Number/Date
7. LOOK UP the Exact or Lower/Greater Approximate
Text/Number/Date
What is out of the scope of this book?

 HLOOKUP
 VBA LOOKUP formulas
 Multiple matches LOOKUP

Excel-Spreadsheet-Authors.com 12 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

 Sum, Count and other operations based on criteria (SUMIF,


COUNTIF, SUMIFS, COUNTIFS, etc)
 Examples with LOOKUP formulas embedded in other formulas

Excel-Spreadsheet-Authors.com 13 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

How to get the Most of this eBook


I recommend you to read the book from the beginning but you can jump
to the LOOKUP case or section you are interested in, here’s how to do it:
 Use the TOC provided at the beginning of this book. You dispose of
a Brief TOC and a Detailed TOC (each entry is a link)
 Google this eBook, search info by pressing CTRL + F (the eBook is
keyword rich, hopefully you will find what are you looking for)
 Use the TOC pane provided at the left of your PDF Reader
Application
 Use the partial TOC located at the end of each section (each entry is
a link)
Regarding conventions used in this book, see below:
 Identify Frontend (needle) in graphics through green color
 Identify Backend table (haystack) in graphics through gray color
 Identify the index column in graphics through red border rectangle
 Identify lookup values (in the lookup array) in graphics through red
filled rectangle and a red check
 Indentify the Frontend in text as: needle, found value, lookup value,
lookup_value
 Identify the backend in text as: haystack, list, table array, lookup
list, lookup array, table_array
 Index column is the column at which the LOOKUP formula searches
 Look up is sometimes referred as: search, give me
Regarding the formulas and functions used in this book, see below:

Grasp the syntax and basic philosophy behind each LOOKUP formula used
so you can interpret the examples quickly (there is no explanation
provided).

Let’s use the table below as an example…

Excel-Spreadsheet-Authors.com 14 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

VLOOKP 0
VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)
Where:

 lookup_value It is the value you want to search in table_array. For


example: 78%

 table_array It is the array where the left column (index column)


contains the exact lookup_value. This index column does not need
to be sorted. In above table: A2:C6

 col_index_num It is the number of the column with the attributes


you want to show for the lookup_value. In above table: 1 for %, 2
for Grade and 3 for Definition

 range_lookup = 0 (exact match)

VLOOKUP 1
VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)
Where:

 table_array It is the array where the left column contains the


exact or the approximate lookup_value. This index column need to
be sorted ascending. In above table: the % column

 range_lookup = 1 or omitted (approximate match)

VLOOKUP is not reconfigurable to search a non-left index column so the


quickest way to search data in these circumstances is by using INDEX and
MATCH.

INDEX and MATCH


INDEX(array,row_num,column_num)

Where:

 array It is the array containing the index column and columns with
attributes. The index column is not necessarily the left one. In
above table: A2:C6

 row_num It is found by a MATCH function

Excel-Spreadsheet-Authors.com 15 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

 column_num It is the number of the column with the attributes


you want to show for lookup_value (found by a MATCH function). It
has the same function that “col_index_num”

MATCH(lookup_value,lookup_array,match_type)

Where:

 lookup_value It is the value you want to search in lookup_array


(the same concept as VLOOKUP)

 lookup_array It is the column array (index column) that contains


the lookup_value. This index column does not need to be sorted
when match_type is 0. Sort it ascending when match_type is 1 (less
than) and descending when match_type is -1 (greater than). It is
not necessarily the leftmost one. For example, it could be: A2:A6,
B2:B6 or C2:C6

 match_type resembles the “range_lookup” VLOOKUP argument.


Its values are: 0 for “exact match”, 1 for “less than match”, -1 for
“greater than match”

Array Formulas
They evaluate arrays in functions that typically support a cell reference
only, for example:

The function EXACT evaluates only individual cells: =EXACT(A2,B2) but as


an array formula it evaluates arrays, see below…

 {=INDEX(Haystack!$A$2:$C$7,MATCH(TRUE,EXACT(Haystack!$
B$2:$B$8,A2),0),1)}

 {=INDEX(Haystack!$A$2:$D$7,MATCH(A2,MONTH(Haystack!$B
$2:$B$7),0),3)}

You need to press CTRL+SHIFT+ENTER after writing or editing the


formula in a cell. They are also known as CSE formulas.

SUMPRODUCT
SUMPRODUCT is a kind of built-in Array Formula. It only serves to
retrieve numeric fields.

Excel-Spreadsheet-Authors.com 16 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

The syntax is: SUMPRODUCT(array1,array2,array3, ...) but it can take the


form:

SUMPRODUCT((array1=condition1)*(array2=condition2)*array_attribute)

What does this mean?

The formula will retrieve the cell in which both conditions are true:

SUMPRODUCT(1*1*attribute)

If one condition is false then you would have:

SUMPRODUCT(1*0*attribute)

Finally, the examples and guidelines provided here were tested on Excel
2007; they consider that the table array is located in a lookup sheet (I
called it “Haystack”) and the LOOKUP formulas are in some frontend
sheet (I called it “Frontend”).

Well, now it is time to get started…

Excel-Spreadsheet-Authors.com 17 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Lookup/Search/Fetching Principles for Unique


Match
The magic phrase here is: "Give me the Attributes about this item".

Excel disposes of several tools to perform this kind of queries: Pivot


Tables and Filter command. But, why you need to search tables with
formulas?

You need individual items at a particular place or inside other formulas.

PT and Filter command are useful but not in all circumstances. PT


retrieves data powerfully but in symmetric format and Filter is only
applicable on the same table.

You won’t send a report to your boss with a note indicating which
criteria to apply in Autofilter (Excel does not possess a “Save Filter”
command). This is the reason to use LOOKUP formulas: VLOOKUP,
VLOOKUP + Helper columns, INDEX and MATCH, SUMPRODUCT, Array
formulas, etc.

Well. there are underlying principles worth talking now.

What does LOOKUP term stand for?

Give me attributes of the index column entry that matches with


any given criteria.

In more friendly terms:

 Give me the phone number of this employee

 Give me the price of this product id

 Who had the biggest sales on this quarter

 Which is the seat number of the person with “Jones” surname

The main characteristic of a LOOKUP operation are:

 Frontend the cell on which you put the lookup formula that search
data in the Backend list (lookup array)
 Backend the list (lookup array) from which the lookup formula in
the Frontend take the data

Excel-Spreadsheet-Authors.com 18 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

1. LOOK UP a Number/Date/Text Equal to…


Imagine you are attending the front desk of a tools-warehouse and a
client needs to buy a hammer, here the sequence:
Client: Good morning sir, how much is the hammer model 51-166R from
Stanley?
You: wait 15 seconds please… you search your database by model and
find the price. It is $24,5 Sir. You found a Needle in the haystack.
Client: I will buy it
This is a common LOOKUP moment. There is more, for example:
 Clients contact data
 Employee register
 Vendors list
 Product codes
 Events dates
 Business cities ranking
 And more…
Here is the content of this section…
 Example 1 – LOOK UP a text
 Example 2 – LOOK UP a Date
 Main Limitations/Problems with VLOOKUP Exact Match
 Example 3 - LOOK UP a Text that is not Located in a Left Index Column
 Example 4 - LOOK UP a Date that is not Located in a Left Index
Column
 Build a Strong VLOOKUP Exact Match with this Checklist

Excel-Spreadsheet-Authors.com 19 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

1.1. Example 1 – LOOK UP a text


The needles…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to VLOOKUP exact match (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formulas in B2 and C2 respectively


=VLOOKUP(A2,Haystack!$A$2:$E$12,2,0)

Excel-Spreadsheet-Authors.com 20 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Avoid mistakes

Take care when you look up numbers with decimal places, the number
that you see on the screen is not necessarily the number Excel deal with.
For example: 5.18 may be 5.179.

There is a workaround to search numbers with decimals see the example:


Example 7 – LOOK UP a Number with Decimal Places

Excel-Spreadsheet-Authors.com 21 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

1.2. Example 2 – LOOK UP a Date


The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to VLOOKUP exact match (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2: =VLOOKUP(A2,Haystack!$A$2:$C$12,2,0)

Notes

You can use:


=VLOOKUP(DATEVALUE("10/12/2007"),Haystack!$A$2:$C$12,2,0) or
=VLOOKUP(DATE(2007,10,12),Haystack!$A$2:$C$12,2,0)

Excel-Spreadsheet-Authors.com 22 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Avoid Mistakes.

 Don’t use dates directly in formulas. For example: the formula


=VLOOKUP(10/12/2007,$A$2:$C$12,2,0) or this one
=VLOOKUP(“10/12/2007”,$A$2:$C$12,2,0) will return #N/A

 Enter dates in the correct format, for example: 1/31/2009 is a date


while 31/1/2009 not

Excel-Spreadsheet-Authors.com 23 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

1.3. Main Limitations/Problems with VLOOKUP


Exact Match

“There are various limitations to vlookup/hlookup. Put in another


way, MS has designed these functions with particular need in mind. A
one formula solution for lists organized based on one key column on
the left and several attribute columns on the right.”
Ask for excerpt:
Chandoo, Pointy Haired Dilbert

Chandoo.org

As suggest Chandoo above, these functions were created with some


limitations…

 VLOOKUP 0 searches on a left index column. Why left? Databases


tables have the key column on the left so I assume they consider
this in the design. (INDEX and MATCH allow you to choose the
index column)
 VLOOKUP 0 does not retrieve the location of the found value in
terms or row, column or cell reference. This data is crucial in some
applications, for example: when you want to use adjacent data or
take decisions about what to do next according to the location of
the value. The function MATCH retrieves the row number of the
value found
 VLOOKUP 0 only retrieves the first occurrence. This is especially
dangerous when you use wildcards or when you have duplicates
with wrong attributes
 VLOOKUP 0 searches based on single criteria only. Well, there are
workarounds to overcome this: Helper columns, Array Formulas
and SUMPRODUCT

Sooner or later you face these limitations; for example: you have your
table arranged to lookup based on the product code but a customer brings
a product name.
Well, for this kind of queries, you need to build an advanced LOOKUP
formula; this is the place to INDEX and MATCH power combination…

Excel-Spreadsheet-Authors.com 24 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

1.4. Example 3 - LOOK UP a Text that is not Located


in a Left Index Column
The needles…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formulas in B2 and C2 respectively:


=INDEX(Haystack!$A$2:$E$12,MATCH(A2,Haystack!$B$2:$B$12
,0),1)

Excel-Spreadsheet-Authors.com 25 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Avoid Mistakes

The lookup_array argument of the MATCH function is a one dimension


array, for example: one column/one row, A2:A32, B2:F2. You will receive
a #N/A error when use a greater array (n rows x n columns).

Excel-Spreadsheet-Authors.com 26 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

1.5. Example 4 - LOOK UP a Date that is not Located


in a Left Index Column
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2:


=INDEX(Haystack!$A$2:$C$12,MATCH(A2,Haystack!$C$2:$C$12
,0),1)

Notes

 You can use two hard coded versions: DATEVALUE("10/12/2007")


or DATE(2007,10,12).

 The lookup_array must be a column array Haystack!$B$2:$B$12.

Excel-Spreadsheet-Authors.com 27 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Avoid Mistakes

Don’t use dates directly in formulas, you will receive a #N/A

 =INDEX($A$2:$C$12,MATCH(10/12/2007,$C$2:$C$12,0),1)

 =INDEX($A$2:$C$12,MATCH(“10/12/2007”,$C$2:$C$12,0),1)

Excel-Spreadsheet-Authors.com 28 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

1.6. Build a Strong VLOOKUP Exact Match with this


Checklist

Checklist for VLOOKUP Exact Match


At the Backend (haystack)
Is the lookup index column located at the left?
Is the index column free of duplicates?
Is the index column free of weird characters? For example: "
for inches, m for meters, %, $, extra commas, etc. Use
CLEAN, TRIM, Text to column
Is the list in a lookup sheet?
Is the index column format correct? Date, % be careful
when you look up numbers, precision displayed is not the
number Excel really stores and use in computations
Is the external lookup book referenced? (in case the list is
located in an external workbook)
At the Frontend (needle)
Is the format of the front end cell the same of the backend
index column? Especially in dates. When numbers be careful
about precision displayed, %
Is the lookup_value free of weird characters? Use CLEAN,
TRIM, Text to column
Is the lookup_value referring to a left index_column?
Do you have a #N/A trapping error formula? Use ISERROR,
ISNA, IF. Now you can use IFERROR (faster). #N/A for
VLOOKUP 0 means item not found so you can use a
message to show this or take an action
Is the range_lookup argument not omitted? (Omitted means
TRUE or approximate match)
Is the table_array argument reference set to absolute?
Is the lookup_value correctly entered at the cell? For
example: “Susan Martines” instead of “Susan Martinez”
Is the column number not hard coded? (optional, when you
move, delete, cut columns in the lookup array)

Excel-Spreadsheet-Authors.com 29 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

2. LOOK UP a Text that Begins with/Ends with/


Contains…
Imagine you are a FBI agent studying the last terrorist attack. You have
two lists: the suspects list and the passenger list provided by a given
airline company (they are really various lists from different flights).

You want to know who of the suspects traveled in which flight.

How do you do it?


Let’s assume that the index column [Passenger] is the leftmost one.
You would enter the complete suspect name to search the passenger list
but it is not likely that the names were entered as you type it.
The best way to do it is by using wildcards.
Excel supports the following wildcards:

Use To find
? (question Any single character
mark) For example, sm?th finds "smith"
and "smyth"
* (asterisk) Any number of characters
For example, *east finds
"Northeast" and "Southeast"
~ (tilde) A question mark, asterisk, or
followed by ?, *, tilde
or ~ For example, fy91~? Finds
"fy91?"

The use of the wildcards is very easy, for example:

 Search the text that Contains “ck” with the formula


VLOOKUP(“*ck*”,all the other arguments)

 Search the text that Begins with “Jav” with the formula
MATCH(“Jav*”,all the other arguments)

 Search the text that Ends with “Jones” with the formula
VLOOKUP(“*Jones”,all the other arguments)

Explore this section:

 Example 1 – LOOK UP a Text that Contains “”

Excel-Spreadsheet-Authors.com 30 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

 Example 2 – LOOK UP a Text that Begins with “”

 Example 3 – LOOK UP a text that Ends with “”

 Example 4 – LOOK UP a Text that Contains “” and is not Located in a


Left Index Column

 Example 5 – LOOK UP a Text that Begins with “” and is not Located in


a Left Index Column

 Example 6 – LOOK UP a Text that Ends with “” and is not Located in a


Left Index Column

Excel-Spreadsheet-Authors.com 31 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

2.1. Example 1 – LOOK UP a Text that Contains “”


The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to VLOOKUP exact match (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2:


=VLOOKUP("*"&A2&"*",Haystack!$A$2:$D$11,1,0)

Notes

 The lookup_value could be set in these ways: "*"&A2&"*", "*ck*"


(hard coded) or A2 where the cell would contain *ck*

 VLOOKUP only retrieves the first occurrence

Excel-Spreadsheet-Authors.com 32 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Avoid mistakes

 More than one entry of the index column may meet the condition.

 VLOOKUP is not case sensitive. See LOOK UP a Text Case-Sensitive

Excel-Spreadsheet-Authors.com 33 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

2.2. Example 2 – LOOK UP a Text that Begins with


“”
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to VLOOKUP exact match (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2:


=VLOOKUP(A2&"*",Haystack!$A$2:$D$11,1,0)

Notes

 The lookup_value could be set in these ways: A2&"*", "Jav*" (hard


coded) or A2 where the cell would contain Jav*

 VLOOKUP only retrieves the first occurrence

Excel-Spreadsheet-Authors.com 34 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

2.3. Example 3 – LOOK UP a text that Ends with “”


The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to VLOOKUP exact match (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formulas in B2 and C2 respectively:


=VLOOKUP("*"&A2,Haystack!$A$2:$D$11,1,0)

Notes

 The lookup_value could be set in these ways: "*"&A2, "*Jones”


(hard coded) or A2 where the cell would contain *Jones

 VLOOKUP only retrieves the first occurrence

Excel-Spreadsheet-Authors.com 35 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

2.4. Example 4 – LOOK UP a Text that Contains “”


and is not Located in a Left Index Column
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2:


=INDEX(Haystack!$A$2:$D$11,MATCH("*"&A2&"*",Haystack!$
B$2:$B$11,0),2)

Notes

 The lookup_value for the MATCH function could be set in these ways:
"*"&A2&"*", "*ck*" (hard coded) or A2 where the cell would contain
*ck*

 MATCH only retrieves the first occurrence

Excel-Spreadsheet-Authors.com 36 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

2.5. Example 5 – LOOK UP a Text that Begins with


“” and is not Located in a Left Index Column
The needles…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2:


=INDEX(Haystack!$A$2:$D$11,MATCH(A2&"*",Haystack!$B$2:$
B$11,0),2)

Notes

 The lookup_value for the MATCH function could be set in these ways:
A2&"*", "Jav*" (hard coded) or A2 where the cell would contain Jav*

 MATCH only retrieves the first occurrence

Excel-Spreadsheet-Authors.com 37 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

2.6. Example 6 – LOOK UP a Text that Ends with “”


and is not Located in a Left Index Column
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2:


=INDEX(Haystack!$A$2:$D$11,MATCH("*"&A2,Haystack!$B$2:$
B$11,0),2)

Notes

 The lookup_value for the MATCH function could be set in these ways:
"*"&A2, "*Jones” (hard coded) or A2 where the cell would contain
*Jones

 MATCH only retrieves the first occurrence

Excel-Spreadsheet-Authors.com 38 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

3. LOOK UP a Text Case-Sensitive


VLOOKUP is not case sensitive. What does this mean? The formula
=VLOOKUP(“*Jones”, all the other arguments) produces the same result
than =VLOOKUP(“*jones”, All the other arguments).

You need the different result in many circumstances; for example, when
you search:

 ASCII codes

 Product codes

 Passwords

 User names

 Any other case in which you want to return a different value if value
is “A” or “a”; for example to compare index columns from different
tables

But…

How to build a case sensitive lookup formula?

You need to use INDEX and MATCH Array Formulas or VLOOKUP + Helper
Columns, two of the more powerful workarounds in Excel.

Here you have two examples…

 Example 1 – LOOK UP a Case Sensitive Text Using an Array Formula

 Example 2 – LOOK UP a Case Sensitive Text Using SUMPRODUCT

Excel-Spreadsheet-Authors.com 39 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

3.1. Example 1 – LOOK UP a Case Sensitive Text


Using an Array Formula
The needles…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2 and B3 respectively:


{=INDEX(Haystack!$A$2:$C$7,MATCH(TRUE,EXACT(Haystack!$
B$2:$B$8,A2),0),1)}

Notes

 Don’t forget to press CTRL+SHIFT+ENTER

Excel-Spreadsheet-Authors.com 40 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Avoid mistakes

Take care of these formulas that appear in some Forums as a solution.


They are solutions but have a weakness.

 =IF(EXACT(A2,VLOOKUP(A2,Haystack1!$A$2:$C$7,1,0)),VLOOKUP(
A2,Haystack1!$A$2:$C$7,1,0),"No exact match")

What’s the problem with the formula?

It may return “No exact match” when searching “Taylt” because the index
column has “taylt” before “Taylt”.

 {=INDEX(Haystack!$A$2:$C$7,MATCH(CODE(A2),CODE(Haystack!
$B$2:$B$7),0),1)}

What’s the problem with the formula?

It only evaluates the first character. For example: CODE(A)=65 while


CODE(a)=97 then CODE(aB) is equal to CODE(ab)

Excel-Spreadsheet-Authors.com 41 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

3.2. Example 2 – LOOK UP a Case Sensitive Text


Using SUMPRODUCT
The needles…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2 and B3 respectively:


=SUMPRODUCT((EXACT(Haystack!$B$2:$B$7,A2))*Haystack!$C
$2:$C$7)

Notes

 SUMPRODUCT only retrieves numeric values. The array


Haystack!$C$2:$C$7 must be numeric or date only. When you use
SUMPRODUCT with text arrays you will receive a #VALUE! Error

 Don’t forget to format cells B2 and B3 as dates

Excel-Spreadsheet-Authors.com 42 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4. LOOK UP Two Index Columns and other


Advanced LOOKUP Formulas
Imagine you are the Sales Manager of a retailer company; you want to
know the amount of the order “00226” made by “Susan Wilson” in
August. Susan is a customer who may have more than one order in that
month.

That’s not all, imagine you want to know the greater order made by
“Susan Wilson” on December.

The kinds of multiple index column criteria are endless. For example:

 Equal to + Equal to

 Equal to + Max

 Contains + Equal to

 And more…

Pivot Tables and Filter command allow you to do these kind of queries
easily but the fact is that you need that data in a given cell or inside any
given formula.

Unfortunately, neither Excel VLOOKUP nor INDEX and MATCH allow you to
do it directly. Hopefully, there are a lot of workarounds: SUMPRODUCT,
VLOOKUP + Helper Columns, INDEX and MATCH Array Formulas, INDEX
and MATCH Array Formulas + Helper columns.

You will find those examples and more in this section:

 Example 1 – LOOK UP a Text and a Number Located in Two Index


Columns Using a Helper Column

 Example 2 – LOOK UP a Text and a Number Located in Two Index


Columns Using SUMPRODUCT

 Example 3 – LOOK UP a Text and a Number in Two Index Columns


Using an Array Formula

 Example 4 – LOOK UP a Month Using a Helper Column

 Example 5 – LOOK UP a Month Using SUMPRODUCT

Excel-Spreadsheet-Authors.com 43 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

 Example 6 – LOOK UP a Month Using an Array Formula

 Example 7 – LOOK UP a Number with Decimal Places

 Example 8 – LOOK UP the Last Instance of a Value

 Example 9 – LOOK UP the Most Frequent Value

 Example 10 – LOOK UP a Value Based on Index Column and Index Row

 Example 11 – LOOK UP

 Example 12 – LOOK UP Multiple Index Column Criteria

Excel-Spreadsheet-Authors.com 44 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4.1. Example 1 – LOOK UP a Text and a Number


Located in Two Index Columns Using a Helper
Column
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

2. Prepare the Helper column with the formula =B2&C2. You can use
CONCATENATE(B2,C2)

At the Frontend (needle)

3. Write the formulas in C2:


=VLOOKUP(CONCATENATE(A2,B2),Haystack!$A$2:$F$12,6,0)

Excel-Spreadsheet-Authors.com 45 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4.2. Example 2 – LOOK UP a Text and a Number


Located in Two Index Columns Using SUMPRODUCT
The needles…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

1. Write the formula in C2:


=SUMPRODUCT((Haystack!$A$2:$A$12=A2)*(Haystack!$B$2:$
B$12=B2)*Haystack!$E$2:$E$12)

Notes

SUMPRODUCT only retrieves numeric values. The array


Haystack!$E$2:$E$12 must be numeric or date only. When you use
SUMPRODUCT with text arrays you will receive a #VALUE! Error

Excel-Spreadsheet-Authors.com 46 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4.3. Example 3 – LOOK UP a Text and a Number in


Two Index Columns Using an Array Formula
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in C2: {


=INDEX(Haystack!$A$2:$E$12,MATCH(A2&B2,Haystack!$A$2:$
A$12&Haystack!$B$2:$B$12,0),5)}

Notes

 Don’t forget to press CTRL+SHIFT+ENTER

 You can use CONCATENATE function instead of &

 You can use the formula:


{=INDEX(Haystack!$A$2:$E$12,MATCH(1,(Haystack!$A$2:$A$1
2=A2)*(Haystack!$B$2:$B$12=B2),0),5)}

Excel-Spreadsheet-Authors.com 47 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4.4. Example 4 – LOOK UP a Month Using a Helper


Column
The needle…

The haystack (Helper column)…

How to…
At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

2. Prepare the Helper column with the function MONTH

At the Frontend (needle)

3. Write the formula in B2:


=VLOOKUP(A2,Haystack!$A$2:$E$7,3,0)

Notes

 You can prepare the Helper column with the functions: YEAR,
MONTH, DAY, WEEKDAY or use a specific date criteria with IF,
AND, OR functions

Excel-Spreadsheet-Authors.com 48 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4.5. Example 5 – LOOK UP a Month Using


SUMPRODUCT
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2:


=SUMPRODUCT((MONTH(Haystack!$B$2:$B$7)=A2)*Haystack!
$C$2:$C$7)

Notes

 You can use the formula:


=SUMPRODUCT((Haystack!$B$2:$B$7>=DATEVALUE("06/01/2
009"))*(Haystack!$B$2:$B$7<=DATEVALUE("06/30/2009"))*H
aystack!$C$2:$C$7)

 You can use the functions: YEAR, MONTH, DAY, WEEKDAY

Excel-Spreadsheet-Authors.com 49 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4.6. Example 6 – LOOK UP a Month Using an Array


Formula
The needle…

The haystack…

How to…
At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2:


{=INDEX(Haystack!$A$2:$D$7,MATCH(A2,MONTH(Haystac
k!$B$2:$B$7),0),3)}

Notes

 Don’t forget to press CTRL+SHIFT+ENTER

 You can use the functions: YEAR, MONTH, DAY, WEEKDAY

Excel-Spreadsheet-Authors.com 50 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4.7. Example 7 – LOOK UP a Number with Decimal


Places
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2:


{=INDEX(Haystack!$A$2:$E$14,MATCH(A2,ROUND(Haystack!E2
:E14,2),0),1)}

Notes

 Don’t forget to press CTRL+SHIFT+ENTER

Excel-Spreadsheet-Authors.com 51 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Avoid mistakes

 Omit the % symbol. Use the decimal version instead. For example
to look 2.5% use 0.025

 Be aware if percentages have decimal places, in such cases use


ROUND

 Take care when you look up numbers with decimal places, the
number that you see on the screen is not necessarily the number
Excel deal with. For example: 5.18 may be 5.179

 Use approximate match but be aware that you may get the next
value. For example (in the table above): the found-value for
456.32 would be 342.11 instead of 456.32335

Excel-Spreadsheet-Authors.com 52 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4.8. Example 8 – LOOK UP the Last Instance of a


Value
The needle…

The haystack…

How to…
At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2:


=LOOKUP(2,1/(Haystack!A2:B9=A2),Haystack!B2:B9)

Notes

 You can also search the last item by using a Helper column (non-
left) with the numbers: 1, 2, 3, etc and then sorting it
descending. Then use VLOOKUP 0

Excel-Spreadsheet-Authors.com 53 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4.9. Example 9 – LOOK UP the Most Frequent Value


The needle…

The haystack…

How to…
At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in A2: {


=INDEX(Haystack!$A$2:$B$9,MATCH(MAX(COUNTIF(Hays
tack!$A$2:$A$9,Haystack!$A$2:$A$9)),COUNTIF(Haystack
!$A$2:$A$9,Haystack!$A$2:$A$9),0),1)

Notes

 Don’t forget to press CTRL+SHIFT+ENTER

 You can use MODE function to retrieve the most frequent number

Excel-Spreadsheet-Authors.com 54 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4.10. Example 10 – LOOK UP a Value Based on Index


Column and Index Row
The needle…

The haystack…

How to…
At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in C2:


=INDEX(Haystack!$A$1:$F$12,MATCH(B2,Haystack!$A$1:
$A$12,0),MATCH(A2,Haystack!$A$1:$F$1,0))

Excel-Spreadsheet-Authors.com 55 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4.11. Example 11 – LOOK UP in Reverse Mode


Reverse lookup

The needle…

The haystack…

How to…
At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2 and C2 respectively:


=INDEX(Haystack!$A$1:$H$1,MAX(INDEX((Haystack!$B$2
:$H$8=$A2)*COLUMN(Haystack!$B$1:$H$1),0))) and
=INDEX(Haystack!$A$1:$A$8,MAX(INDEX((Haystack!$B$2
:$H$8=$A2)*ROW(Haystack!$A$2:$A$8),0)))

Excel-Spreadsheet-Authors.com 56 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

4.12. Example 12 – LOOK UP Multiple Index Column


Criteria
The needle…

The haystack…

How to…
At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in C2:


{=INDEX(Haystack!$A$2:$C$5,MATCH(1,(Haystack!$A$2:$
A$5=A2)*(Haystack!$B$2:$B$5<=B2),0),3)}

Notes

 Don’t forget to press CTRL+SHIFT+ENTER

Excel-Spreadsheet-Authors.com 57 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

5. LOOK UP the Number/Date/Text that is the


Max/Min, newest/Oldest, A/Z
Imagine you are the Sales Manager of a retailer company; you want to
know the Salesman who sold more.

This kind of LOOKUP is different. You don’t have a value to search on the
list; I would call it open LOOKUP.

You search an unknown item. For example:

 Biggest quantity

 Most recent/oldest date

 The first item in alphabetical order

 And more…

Pivot Table and Filter command do that very easily but you are here to
search data in tables and put it in a particular cell or inside a formula.

INDEX and MATCH formula allows you to do it.

Here are some examples:

 Example 1 – LOOK UP the Biggest Quantity

 Example 2 – LOOK UP the Newest Date-Time

Excel-Spreadsheet-Authors.com 58 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

5.1. Example 1 – LOOK UP the Biggest Quantity


The needles…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formulas in B2 and B3 respectively:


=INDEX($A$2:$D$7,MATCH(MAX($D$2:$D$7),$D$2:$D$7,0),1)
and
=INDEX($A$2:$D$7,MATCH(MIN($D$2:$D$7),$D$2:$D$7,0),1)

Excel-Spreadsheet-Authors.com 59 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

5.2. Example 2 – LOOK UP the Newest Date-Time


The needles…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in A2, B2, C2 respectively:


=INDEX(Haystack!$A$2:$C$9,MATCH(MAX(Haystack!$C$2:$C$9
),Haystack!$C$2:$C$9,0),3)

Notes

 Excel Dates are numbers. They are sequential numbers from 1 to


2,958,465 (01/01/1900 to 31/12/9999). Read the article: Excel Date

 You can use MIN function to get the oldest date

Excel-Spreadsheet-Authors.com 60 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Avoid Mistakes:

Don’t use dates directly in formulas

=INDEX($A$2:$C$12,MATCH(10/12/2007,$C$2:$C$12,0),1)) will return


#N/A

=INDEX($A$2:$C$12,MATCH(“10/12/2007”,$C$2:$C$12,0),1)will return
#N/A

Excel-Spreadsheet-Authors.com 61 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

6. LOOK UP the Exact or Lower Approximate


Text/Number/Date
Imagine you are a teacher and that you
need to classify your students’ performance
according to the Grade table shown at the
left.

Students’ scores will fall in one of these


ranges, eventually in the exact percentage.

In this situation, exact match is not enough, you need to use a value
when the searched value is not on the table.

VLOOKUP allows you to search exact or approximate values. It has two


special considerations:

 Range_lookup set to 1 or omitted

 Index column in table_array must be in ascending order

Why ascending? VLOOKUP 1 start looking for searched value from the
bottom and then, it uses the exact match or the next largest value that is
less than lookup_value is returned, what does this mean? the left most
one. See graphic below…

Here is the content of this section:

 Example 1 – LOOK UP an Exact or Approximate Number (case 1)

 Example 2 – LOOK UP an Exact or Approximate Text

 Example 3 – LOOK UP an Exact or Approximate Number (case 2)


Excel-Spreadsheet-Authors.com 62 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

 Example 4 – LOOK UP an Exact or Approximate Date

 Example 5 – LOOK UP Exact or Approximate Percentages

 Main Limitations/Problems with VLOOKUP Approximate Match

 Build a Strong VLOOKUP Approximate Match with this Checklist…

Excel-Spreadsheet-Authors.com 63 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

6.1. Example 1 – LOOK UP an Exact or Approximate


Number (case 1)
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup approximate match


(see table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formula in B2:


=VLOOKUP(A2,Haystack!$A$2:$C$10,1)

Notes

 You can omit range_lookup

 Don’t forget to sort ascending the lookup array based on the index
column

Excel-Spreadsheet-Authors.com 64 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

6.2. Example 2 – LOOK UP an Exact or Approximate


Text
The needles…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup approximate match


(see table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formulas in B2 and C2 respectively


=VLOOKUP(A2,Haystack!$A$2:$C$6,3,1) and
=VLOOKUP(A2,Haystack!$A$2:$C$6,1,1)

Notes

 You can omit range_lookup

 Don’t forget to sort ascending the lookup array based on the index
column

Excel-Spreadsheet-Authors.com 65 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

6.3. Example 3 – LOOK UP an Exact or Approximate


Number (case 2)
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup approximate match


(see table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formulas in B2:


=VLOOKUP(A2,Haystack!$A$2:$B$5,2,1)

Notes

 You can omit range_lookup

 Don’t forget to sort ascending the lookup array based on the index
column

Excel-Spreadsheet-Authors.com 66 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

6.4. Example 4 – LOOK UP an Exact or Approximate


Date/Time
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup approximate


match (see table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formulas in B2:


=VLOOKUP(A2,Haystack!$A$2:$C$4,3,1)

Notes

 Set the B2 format to %

 You can use


=VLOOKUP(DATEVALUE("7/22/2009"),Haystack!$A$2:$C$4,3
,1) or =VLOOKUP(DATE(2009,7,22),Haystack!$A$2:$C$4,3,1)

 Dates are numbers. Read: http://www.excel-spreadsheet-


authors.com/excel-date.html

 You can omit range_lookup

 Don’t forget to sort ascending the lookup array based on the index
column

Excel-Spreadsheet-Authors.com 67 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

6.5. Example 5 – LOOK UP Exact or Approximate


Percentages
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup approximate


match (see table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formulas in B2:


=VLOOKUP(A2,Haystack!$A$2:$C$6,2,1)

Notes

 You can use: =VLOOKUP(75%,Haystack!$A$2:$C$6,2,1) or


=VLOOKUP(0.75,Haystack!$A$2:$C$6,2,1)

 Take care of decimal places, for example: 0.75 may return #N/A
because the backend number is 0.748. Excel shows 0.75 (75%) but
internally manage all the digits. See: Example 7 – LOOK UP a
Number with Decimal Places

 You can omit range_lookup

 Don’t forget to sort ascending the lookup array based on the index
column

Excel-Spreadsheet-Authors.com 68 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Avoid mistakes

Don’t hard code percentages this way because you will receive a #N/A
error:

 =VLOOKUP("0.75",Haystack!$A$2:$C$6,2,1)

 =VLOOKUP("75%",Haystack!$A$2:$C$6,2,1)

Excel-Spreadsheet-Authors.com 69 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

6.6. Main Limitations/Problems with VLOOKUP


Approximate Match
 Less than but not greater than. Match has both options and exact
 VLOOKUP 1 searches on a left index column. Why left? Database
tables have the key column on the left so I assume they consider
this in the design. (INDEX and MATCH allow you to choose the
index column)
 VLOOKUP 1 does not retrieve the location of the found value in
terms or row, column or cell reference. This data is crucial in some
applications, for example: when you want to use adjacent data or
take decisions about what to do next according to the location of
the value. The function MATCH retrieves the row number of the
value found
 VLOOKUP 1 only retrieves the first occurrence. This is especially
dangerous when you use wildcards or when you have duplicates
with the wrong data
 VLOOKUP 1 searches based on single criteria only. Why? Well, there
are workarounds: Helper columns, array formulas and
SUMPRODUCT
 VLOOKUP 1 result is affected by a table not sorted ascending
 VLOOKUP 1 does not allow you to decide which of the nearest
values to choose (the lower or the greater one)

Excel-Spreadsheet-Authors.com 70 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

6.7. Build a Strong VLOOKUP Approximate Match


with this Checklist…

Checklist for VLOOKUP Exact Match


At the Backend (haystack)
Is the lookup index_column located at the left?
Is the list free of duplicates?
Is the index column free of weird characters? For example: "
for inches, m for meters, %, $, extra commas, etc. Use
CLEAN, TRIM, Text to column
Is the list in a lookup sheet?
Is the external lookup book referenced
Is the index column format correct? Date, % be careful
when you look up numbers, precision displayed is not the
number Excel really stores and use in computations
Is the index column sorted ascending (when use match
option -1 sort descending)
At the Frontend (needle)
The format of the front end cell is the same of the backend
index_column? Especially in dates. When numbers be
careful about precision displayed
Is the lookup_value free of weird characters? Use CLEAN,
TRIM, Text to column
Is the column number not hard coded? (optional, when you
move, delete, cut columns in the lookup array)
Is the lookup_value referring to a left index_column?
Do you have a #N/A trapping error formula? Use ISERROR,
ISNA, IF. Now you can use IFERROR (faster) you can use
the lowest value instead (and color it). #N/A for VLOOKUP 0
means item not found so you can use a message to show
this or take an action
Is the range_lookup argument set to 1 or omitted?
Is the table_array argument reference set to absolute?
Is the lookup_value correctly typed

Excel-Spreadsheet-Authors.com 71 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

7. LOOK UP the Exact or Lower/Greater


Approximate Text/Number/Date
Imagine the same student’s grades table.

Now think a student that scored near any


given grade but is assigned the lower one.
Students’ scores must have a kind of
rounding sensitivity.

VLOOKUP 1 is unfair. What does this mean?

A student with 72% will receive a C and a student with 89.9% will receive
a C too (he deserves a B).

How to build a smart LOOKUP formula to decide which value to return?

You need INDEX and MATCH (match_option = less than) and some
midpoint criterion to decide.

Here’s how to calculate a midpoint to decide which value to retrieve…

Excel-Spreadsheet-Authors.com 72 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

The midpoint for the example above is 80, that is (90-70)/2 + 70.
If found-value for 89.9% (70) is less than or equal than 80; then
returned-value is 70, if not, returned-value is 90 (the value located one
row below).
See this example…

Excel-Spreadsheet-Authors.com 73 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

7.1. Example 1 - LOOK UP an Exact or


Lower/Greater Approximate Number
The needle…

The haystack…

How to…

At the Backend (haystack)

1. Prepare the table_array to be ready to lookup unique entries (see


table_array troubleshooting in page 75)

At the Frontend (needle)

2. Write the formulas in B2:


=IF(A2<=(INDEX(Haystack!$A$2:$C$10,MATCH(A2,Haystack!$
A$2:$A$10,1)+1,1)-
INDEX(Haystack!$A$2:$C$10,MATCH(A2,Haystack!$A$2:$A$10,
1),1))/2+INDEX(Haystack!$A$2:$C$10,MATCH(A2,Haystack!$A
$2:$A$10,1),1),INDEX(Haystack!$A$2:$C$10,MATCH(A2,Haysta
ck!$A$2:$A$10,1),1),INDEX(Haystack!$A$2:$C$10,MATCH(A2,H
aystack!$A$2:$A$10,1)+1,1))

Notes

Understand the formula better by using words: IF(lookup_value<=midpoint,


use the returned value, if not use the value one row below)

Excel-Spreadsheet-Authors.com 74 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Table_array Troubleshooting
 Delete duplicates in Index column, here are several options:

o Remove Duplicates in Excel 2007 by going to:


Design>Tools>Remove Duplicates

o Remove Duplicates manually in Excel 2007 by going to:


Home>Styles>Conditional formatting>Highlight Cells
Rules>Duplicate values

o Remove duplicates in Excel 2003 by going to:


Data>Filter>Advanced Filter>Unique records only

 Delete duplicates in the entire table array for the case or reverse
LOOKUP

 Be sure that the Index column is the leftmost one for VLOOKUP
formulas. To move it proceed this way: Cut the column, right click
on the leftmost column header and choose Insert Cut Cells

 Sort the index column ascending for VLOOKUP 1, and MATCH 1.


Proceed this way:

o Sort in Excel 2007 by doing this: select a cell of the index


column then go to: Data>Sort & Filter>Sort smallest to
largest

o Sort in Excel 2003 by doing this: select a cell of the index


column then go to: standard toolbar and press sort ascending
button or by going to: Data>Sort>Sort by>Ascending>Ok

 Sort the index column descending for MATCH -1

 Delete leading and trailing spaces from index column. To clean


spaces use: TRIM, Text to Columns

 Delete nonprintable characters in the index column. Use CLEAN

 Format the index column according to the data it contains. For


example: numbers must be free of m for meters, “ for inches, etc.
they not be stored as texts. Dates must be entered as serial
numbers and not as SEPT09, etc

Excel-Spreadsheet-Authors.com 75 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

FAQ
 The VLOOKUP is double checked but I keep getting #N/A.
Anyone knows why?

Try one of these solutions:

 Check if the index column in the lookup array is the leftmost one

 Delete leading and trailing spaces in the index column and in the
lookup_value cell

 Check format. Especially in dates. For example: 01/30/2009 is a


date while 30/01/2009 not

 Check the lookup_value cell spelling in the frontend

 Enter range_lookup argument as 0. Omitted means 1 (approximate)

 What does the 4th VLOOKUP argument mean?

It controls if the formula retrieves the exact match (FALSE or 0) or


approximate match (TRUE or 1)

Omitted range_lookup is 1 by default (TRUE or 1)

 What does False do?

It makes VLOOKUP and MATCH to retrieve the exact match only.

 I get #REF! error, what am I doing wrong?

The col_index_num argument may be greater than the dimension of


table_array. For example: your array has 3 columns and you are
specifying 4.

 I get #VALUE! error, what am I doing wrong?

The col_index_num argument is less than 1

 The vlookup/hlookup returns the first occurrence. Is it


possible to choose which instance to retrieve?

No.

 I want to show a message or value instead of #N/A how do I


do it?

Excel-Spreadsheet-Authors.com 76 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Apply one of these solutions:

 Embed your formula into an IF function. For example:


=IF(ISNA(VLOOKUP(),“Value not found”,VLOOKUP())

 Use IFERROR function (Excel 2007). For example


=IFERROR(VLOOKUP(),“Value not found”). This solution is faster
because Excel evaluates VLOOKUP once

 Can be the col_index_num be zero or negative?

No.

 Is possible to set other than left column to VLOOKUP look


data for?

No. Use INDEX and MATCH instead.

 Can the vlookup/hlookup functions evaluate multiple


conditions?

No but there are various ways to do it:

 Use Helper columns. Create a left column, evaluate two or more


index columns with CONCATENATE, IF, AND, OR functions and then
use VLOOKUP

 Use INDEX and MATCH in Array Formulas

 Use SUMPRODUCT (only retrieves numeric fields)

 I want to sum the values that meet certain criteria and


return it, how can I do it?

Use SUMIF, SUMIFS.

 I want to Count the values that meet certain criteria and


return it, how can I do it?

Use COUNTIF, COUNTIFS.

 Can I return the formatting with VLOOKUP?

No. You need VBA.

 How can I look up data in a non-left index column?

Use INDEX and MATCH formula


Excel-Spreadsheet-Authors.com 77 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

LOOKUP Resources
 http://www.cpearson.com/excel/TablesAndLookups.aspx

 http://www.mvps.org/dmcritchie/excel/vlookup.htm

 http://www.exceltip.com/exceltips.php?view=category&ID=112

 http://chandoo.org/wp/2008/11/19/vlookup-match-and-offset-
explained-in-plain-english-spreadcheats/

Excel-Spreadsheet-Authors.com 78 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Excel Resources
This list is not exhaustive but it includes a lot of the good Excel stuff…

Forums

http://www.mrexcel.com/forum/index.php

http://www.excelforum.com

http://www.eng-tips.com/

http://www.allexperts.com/el/Excel/

http://www.tek-tips.com/

Blogs

http://www.chandoo.org/wp/

http://www.blog.contextures.com/

http://www.blogs.msdn.com/

Articles, tips and more

www.cpearson.com

www.contextures.com/

http://spreadsheetpage.com/

http://www.exceluser.com/

http://www.mvps.org/links.html#Excel

http://www.ozgrid.com/

www.exceltip.com

http://www.excel.tips.net/

http://www.peltiertech.com/

Excel-Spreadsheet-Authors.com 79 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

What Readers Say about Excel-Spreadsheet-


Authors.com…

July 15, 2009

"Hi John... you have very good content


here.

I am subscribing to your blog for my


daily reading list."

Chandoo, Pointy Haired Dilbert


Chandoo.org

See more testimonials

Posted on June 19, 2009 in the LinkedIn group


Microsoft Excel Users. For the article: SUMIF
Multiple - 7 Ways to Sum Values Based on Multiple
Criteria

"This is an excellent article. I have dealt with the


exact issues mentioned here and had not
considered many of the options mentioned.

I am truly interested to discover what other


suggestions and ideas the author may be able to
share."

Robert Parker
Project Manager at LeTourneau Technologies
Longview, Texas Area

Excel-Spreadsheet-Authors.com 80 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

August 11, 2009

"Thanks - lots of useful articles on


Excel"

Danielle Stein Fairhurst


Financial Modeling in Excel Online Courses

July 10, 2009

"I am a civil engineer by profession and


developed many Excel applications for
my own and others use enabling us to
work smarter.

I visited your website; it is quite unique in its


design and of course very informative. No doubt I
will be visiting your website very often."

Keith Gunaratne
Chartered Civil Engineer and Information
Management Consultant
Director at JIK Solutions
London, United Kingdom

Excel-Spreadsheet-Authors.com 81 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Get New eBooks at ESA Store


Title: The Missing Excel User Guide
to Lookup Data from Lists Using
Formulas Series

Description: become a Data God with


all the formulas to retrieve data from
lists.

 Volume 2 - The Missing LOOK


UP Guide for Multiple Matches

 Volume 3 - The Missing LOOK


UP Guide for Single Match Using
HLOOKUP and INDEX and
MATCH

 Volume 4 - Advanced LOOKUP


Formulas Using VBA

Title: 21 Underground Excel Tips


Volume 1

Description: Boost your productivity


with 21 not-so-known Tips for
immediate application.

It is FREE

Download

Get more eBooks at ESA store

Excel-Spreadsheet-Authors.com 82 | P a g e
The Missing Excel User Guide to Look Up Data from Lists Using Formulas - Vol 1©

Want a Career Boost?


Get Excel Awareness…

Visit Excel-Spreadsheet-Authors.com

Excel-Spreadsheet-Authors.com 83 | P a g e

Anda mungkin juga menyukai