0% found this document useful (0 votes)
8 views70 pages

AE Unit1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 70

Basics of Excel

***What is Excel?

Excel is pronounced "Eks - sel"

It is a spreadsheet program developed by Microsoft. Excel organizes data in


columns and rows and allows you to do mathematical functions. It runs on
Windows, macOS, Android and iOS.

The first version was released in 1985 and has gone through several changes
over the years. However, the main functionality mostly remains the same.

Excel is typically used for:

 Analysis
 Data entry
 Data management
 Accounting
 Budgeting
 Data analysis
 Visuals and graphs
 Programming
 Financial modeling
 And much, much more!

***Why Use Excel?


 *It is the most popular spreadsheet program in the world
 *It is easy to learn and to get started.
 *The skill ceiling is high, which means that you can do more advanced things
as you become better
 *It can be used with both work and in everyday life, such as to create a
family budget
 *It has a huge community support
 *It is continuously supported by Microsoft
 *Templates and frameworks can be reused by yourself and others, lowering
creation costs

Customizing common options


Excel's structure is made of two pieces, the Ribbon and the Sheet.

Have a look at the picture below. The Ribbon is marked with a red rectangle
and the Sheet is marked with a yellow rectangle:

***First, let's start with explaining the Ribbon.

The Ribbon explained

*The Ribbon provides shortcuts to Excel commands. A command is an action


that allows you to make something happen. This can be explained with an
example is: insert a table, change the font size, or to change the color of a cell.
*The Ribbon may look crowded and hard to understand at first. Don't be
scared, It will become easier to navigate and use as you learn more. Most of
the time we tend to use the same functionalities over again.

*The Ribbon is made up by the App launcher, Tabs, Groups and Commands. In
this section we will explain the different parts of the Ribbon.

**App launcher

The App launcher icon has nine dots and is called the Office 365 navigation bar.
It allows you to access the different parts of the Office 365 suite, such as Word,
PowerPoint and Outlook. App launcher can be used to switch seamlessly
between the Office 365 applications.

**Tabs

The tab is a menu with sub divisions sorted into groups. The tabs allow users to
quickly navigate between options of menus which display different groups of
functionality.

**Groups

The groups are sets of related commands. The groups are separated by the
thin vertical line break.

**Commands

The commands are the buttons that you use to do actions.

Now, let's have a look at the Sheet. Soon you will be able to understand the
relationship between the Ribbon and the Sheet, and you can make things
happen.
**The Sheet explained

The Sheet is a set of rows and columns. It forms the same pattern as we have
in math exercise books, the rectangle boxes formed by the pattern are called
cells.

Values can be typed to cells.

Values can be both numbers and letters:

***Relative Reference

**Introduction

There are two types of cell references: relative and absolute. Relative and
absolute references behave differently when copied and filled to other cells.
Relative references change when a formula is copied to another cell. Absolute
references, on the other hand, remain constant no matter where they are
copied.
**Relative references

By default, all cell references are relative references. When copied across
multiple cells, they change based on the relative position of rows and columns.
For example, if you copy the formula =A1+B1 from row 1 to row 2, the formula
will become =A2+B2. Relative references are especially convenient whenever
you need to repeat the same calculation across multiple rows or columns.

**To create and copy a formula using relative references:

In the following example, we want to create a formula that will multiply each
item's price by the quantity. Instead of creating a new formula for each row,
we can create a single formula in cell D4 and then copy it to the other rows.
We'll use relative references so the formula calculates the total for each item
correctly.

1. Select the cell that will contain the formula. In our example, we'll
select cell D4.

2. Enter the formula to calculate the desired value. In our example,


we'll type =B4*C4.
3. Press Enter on your keyboard. The formula will be calculated, and
the result will be displayed in the cell.
4. Locate the fill handle in the bottom-right corner of the desired cell.
In our example, we'll locate the fill handle for cell D4.

5. Click and drag the fill handle over the cells you want to fill. In our
example, we'll select cells D5:D13.
6. Release the mouse. The formula will be copied to the selected cells
with relative references, displaying the result in each cell.

You can double-click the filled cells to check their formulas for accuracy. The
relative cell references should be different for each cell, depending on their
rows.
***Absolute references

There may be a time when you don't want a cell reference to change when
copied to other cells. Unlike relative references, absolute references do not
change when copied or filled. You can use an absolute reference to keep a row
and/or column constant.

An absolute reference is designated in a formula by the addition of a dollar


sign ($). It can precede the column reference, the row reference, or both.

You will generally use the $A$2 format when creating formulas that contain
absolute references. The other two formats are used much less frequently.

When writing a formula, you can press the F4 key on your keyboard to switch
between relative and absolute cell references.This is an easy way to quickly
insert an absolute reference.
To create and copy a formula using absolute references:

In the example below, we'll use cell E2 (which contains the tax rate of 7.5%) to
calculate the sales tax for each item in column D. To make sure the reference
to the tax rate stays constant—even when the formula is copied and filled to
other cells—we'll need to make cell $E$2 an absolute reference.

1. Select the cell that will contain the formula. In our example, we'll
select cell D4.

2. Enter the formula to calculate the desired value. In our example,


we'll type =(B4*C4)*$E$2, making $E$2 an absolute reference.
3. Press Enter on your keyboard. The formula will calculate, and the
result will display in the cell.
4. Locate the fill handle in the bottom-right corner of the desired
cell. In our example, we'll locate the fill handle for cell D4.

5. Click and drag the fill handle over the cells you want to fill
(cells D5:D13 in our example).
6. Release the mouse. The formula will be copied to the selected
cells with an absolute reference, and the values will be calculated
in each cell.

You can double-click the filled cells to check their formulas for accuracy. The
absolute reference should be the same for each cell, while the other
references are relative to the cell's row.
Be sure to include the dollar sign ($) whenever you're making an absolute
reference across multiple cells. The dollar signs were omitted in the example
below. This caused Excel to interpret it as a relative reference, producing an
incorrect result when copied to other cells.

Using cell references with multiple worksheets

Excel allows you to refer to any cell on any worksheet, which can be especially
helpful if you want to reference a specific value from one worksheet to
another. To do this, you'll simply need to begin the cell reference with
the worksheet name followed by an exclamation point (!). For example, if you
wanted to reference cell A1 on Sheet1, its cell reference would be Sheet1!A1.

Note that if a worksheet name contains a space, you'll need to include single
quotation marks (' ') around the name. For example, if you wanted to
reference cell A1 on a worksheet named July Budget, its cell reference would
be 'July Budget'!A1.
To reference cells across worksheets:

In our example below, we'll refer to a cell with a calculated value between two
worksheets. This will allow us to use the exact same value on two different
worksheets without rewriting the formula or copying data.

1. Locate the cell you want to reference, and note its worksheet. In
our example, we want to reference cell E14 on the Menu
Order worksheet.

2. Navigate to the desired worksheet. In our example, we'll select


the Catering Invoice worksheet.
3. Locate and select the cell where you want the value to appear. In
our example, we'll select cell C4.

4. Type the equals sign (=), the sheet name followed by


an exclamation point (!), and the cell address. In our example,
we'll type ='Menu Order'!E14.

5. Press Enter on your keyboard. The value of the referenced cell


will appear. Now, if the value of cell E14 changes on the Menu
Order worksheet, it will be updated automatically on the Catering
Invoice worksheet.

If you rename your worksheet at a later point, the cell reference will be
updated automatically to reflect the new worksheet name.
If you enter a worksheet name incorrectly, the #REF! error will appear in the
cell. In our example below, we've mistyped the name of the worksheet.
To edit, ignore, or investigate the error, click the Error button beside the cell
and choose an option from the menu.

Protect and unprotect a cell or worksheet in Microsoft Excel

When you create a spreadsheet, you may enter data or formulas that you do
not want other users to change. Protecting a cell or worksheet can be essential
to maintaining the integrity of data and formulas in a spreadsheet.

In Microsoft Excel, you can protect one or more cells, or protect an entire
worksheet, preventing other users from changing the data in the cells or
worksheet. After locking and protecting cells or worksheets, to edit them
again, you need to unprotect them.

**How to protect a cell

To protect a cell in Microsoft Excel, follow the steps below.

1. Select all cells in the worksheet by clicking the Select All button,
found above the row numbers and to the left of the column
headers.

2. Press Ctrl+1 to open the Format Cells window. You can also
use Ctrl+Shift+F combination to open the Format Cells window.

3. In the Format Cells window, click the Protection tab.

4. Uncheck the box for the Locked option, then click OK.

5. In the worksheet, select the cell you want to lock and protect.

If necessary, you can select more than one cell to protect.

6. Open the Format Cells window by pressing Ctrl+1 combination


again.
7. Click the Protection tab, check the box for the Locked option,
then click OK.

8. In the menu bar, click the Review tab.

9. In the Protect group, click the Protect Sheet option.

10.The Protect Sheet window opens. Enter a password for


unlocking the protected cells in the Password to unprotect
sheet text field.

11.In the Allow all users of this worksheet to section, make sure
only the box for the Select unlocked cells option is checked,
then click OK.
12.Enter the password again in the Confirm Password window and
click OK.

How to unprotect a cell or worksheet

To unprotect a cell or worksheet in Microsoft Excel, follow the steps below.

1. In the menu bar, click the Review tab.

2. In the Protect group, click the Unprotect Sheet option.

3. In the Unprotect Sheet sheet window that pops up, enter the
password to unlock the worksheet, then click OK.

Working with basic functions


Figuring out formulas for calculations you want to make in Excel can be tedious
and complicated. Fortunately, Excel has an entire library of functions—
or predefined formulas—you can take advantage of. You may be familiar with
common functions like sum, average, product, and count, but there are
hundreds of functions in Excel, even for things like formatting text, referencing
cells, calculating financial rates, and analyzing statistics.

**Basic functions

A function is a predefined formula that performs calculations using specific


values in a particular order. One of the key benefits of functions is that they
can save you time because you do not have to write the formula yourself. Excel
has hundreds of functions to assist with your calculations.

To use these functions correctly, you need to understand the different parts of
a function and how to create arguments in functions to calculate values and
cell references.

The parts of a function

The order in which you insert a function is important. Each function has a
specific order—called syntax—which must be followed in order for the
function to work correctly. The basic syntax to create a formula with a function
is to insert an equals sign (=), function name (SUM, for example, is the
function name for addition), and argument. Arguments contain the
information you want the formula to calculate, such as a range of cell
references.
Working with arguments

Arguments must be enclosed in parentheses. Individual values or cell


references inside the parentheses are separated by either colons or commas.

 Colons create a reference to a range of cells.

For example, =AVERAGE(E19:E23) would calculate the average of


the cell range E19 through E23.
 Commas separate individual values, cell references, and cell
ranges in parentheses. If there is more than one argument, you
must separate each argument by a comma.

For example, =COUNT(C6:C14,C19:C23,C28) will count all the cells


in the three arguments that are included in parentheses.

To create a basic function in Excel:


1. Select the cell where the answer will appear (F15, for example).
2. Type the equals sign (=), then enter the function name (SUM, for
example).

3. Enter the cells for the argument inside the parentheses.


4. Press Enter, and the result will appear.

Excel will not always tell you if your function contains an error, so it's up to
you to check all of your functions.

**Using AutoSum to select common functions

The AutoSum command allows you to automatically return the results for a
range of cells for common functions like SUM and AVERAGE.

1. Select the cell where the answer will appear (E24, for example).
2. Click the Home tab.
3. In the Editing group, click the AutoSum drop-down arrow and
select the function you want (Average, for example).

4. A formula will appear in E24, the selected cell. If logically placed,


AutoSum will select your cells for you. Otherwise, you will need to
click the cells to choose the argument you want.
5. Press Enter, and the result will appear.

The AutoSum command can also be accessed from the Formulas tab.

You can also use the Alt+= keyboard shortcut instead of the AutoSum
command. To use this shortcut, hold down the Alt key and then press
the equals sign.

**The Function Library

There are hundreds of functions in Excel, but only some will be useful for the
type of data you're working with. There is no need to learn every single
function, but you may want to explore some of the different types to get ideas
about which ones might be helpful to you as you create new spreadsheets.

A great place to explore functions is in the Function Library on the Formulas


tab. Here, you can search and select Excel functions based on categories such
as Financial, Logical, Text, and Date & Time. Click the buttons in the interactive
below to learn more.
**To insert a function from the Function Library:
1. Select the cell where the answer will appear (I6, for example).
2. Click the Formulas tab.
3. From the Function Library group, select the function category you
want. In this example, we'll choose Date & Time.
4. Select the desired function from the Date & Time drop-down
menu. We'll choose the NETWORKDAYS function to count the
days between the order date and receive date in our worksheet.
5. The Function Arguments dialog box will appear. Insert the cursor
in the first field, then enter or select the cell(s) you want (G6, for
example).

6. Insert the cursor in the next field, then enter or select the cell(s)
you want (H6, for example).
7. Click OK, and the result will appear. Our results show that it took
five days to receive the order.

**The Insert Function command

The Insert Function command is convenient because it allows you to search for
a function by typing a description of what you're looking for or by selecting a
category to peruse. The Insert Function command can also be used to easily
enter or select more than one argument for a function.

**Using the Insert Function command

In this example, we want to find a function that will count the total number of
supplies listed in the Office Supply Order Log. The basic COUNT function only
counts cells with numbers; we want to count the cells in the Office Supply
column, which uses text. Therefore, we'll need to find a formula that counts
cells with text.

1. Select the cell where the answer will appear (A27, for example).
2. Click the Formulas tab, then select the Insert Function command.
3. The Insert Function dialog box will appear.
4. Type a description of the function you are searching for, then
click Go (Count cells with text, for example). You can also search
by selecting a category.

5. Review the results to find the function you want (COUNTA, for
example). Click OK.
6. The Function Arguments dialog box will appear. Insert the cursor
in the first field, then enter or select the cell(s) you want (A6:A14,
for example).

7. Insert the cursor in the next field, then enter or select the cell(s)
you want (A19:A23, for example). You can continue to add
additional arguments if needed.
8. Click OK, and the result will appear. Our results show that 14 Total
Supplies were ordered from our log.

What is a Conditional Formula?


A conditional formula in Excel is a formula that makes a logical test of data
using the IF function. It essentially allows you to create a basic logical
argument of “If (this), then (that).” One of the great benefits of using
conditional formulas within Excel is that it’s pretty simple. Conditional
programming is used in web design and development as well, particularly in
the case where a website is visited using different browsers.

**How to Write a Conditional Formula

The basic syntax of the IF formula in Excel is:

=IF(logical_test,[value_if_true],[value_if_false])

logical_test: the condition that you are checking for

[value_if_true]: the result you want if the condition is true

[value_if_false]: the results you want returned if the condition is false

As an example, you can include this formula in cell D2 to list the player with
the highest score:
=IF(B2>C2,B1,C1)

You can also use the AND, OR, and NOT functions to produce TRUE and FALSE
results.

=AND(B2>1,C2>1)

10

=OR(B2>1,C2>1)
=NOT(C2>1)

You can also use <> as an operator in your formula in place of “not equal to”
like so:

=OR(B2<>0,C3<1)
**Why use Conditional Formulas?

At some point in time, when you are faced with a lot of data in your
spreadsheets, you may want to find a way to highlight or “filter” out some of
your data based on specific criteria. For example, if you wanted to see if the
value of a cell in column A is equal to the value of a cell in column B
(duplicates), you can use a conditional formula in column C to give you a TRUE
or FALSE result.

=IF(A1=B1,TRUE,FALSE)

This can be helpful if you are using this formula across a large range of cells
and you want to be able to catch any anomalies. In another example, if you
were trying to determine which cells have values of a certain range, you can
also use the IF function to create a conditional formula like:

=IF(A1>3,TRUE,FALSE)

If your objective is to count how many cells fit a specific criteria (e.g. values
greater than 50), you would probably be better off using the COUNTIF function.
However, the benefit to using basic conditional formulas with the IF function is
that you can use this formula for conditional formatting so you can highlight
cells that match a criteria of your choosing.

=COUNTIF(D2:D5,B1) for cell references and numerical values


=COUNTIF(D2:D5,”Player 1″) for text vaues—don’t forget to include quotation
marks if you’re referring to a text value

**Applications of Conditional Formulas

Finding duplicates across rows or columns


[e.g. =IF(A1=B1,”Same”,”Different”)]

Finding values in a specific range [e.g. values greater than


4: =IF(A1>4,TRUE,FALSE)]

Nested conditional formulas

**Calculate different equations based on different values of a single cell

[e.g. if you’re trying to use a formula that is dependent upon conditions, you
can “nest” your functions (where multiple functions are used within each
other)In this example, if you were to calculate the difference of one player’s
victories over the other (without ending up with negatives) and to also denote
if there is a tie, you could use a formula like:
=IF(B7>C7,B7-C7,IF(C7>B7,C7-B7,”Tie”))

This formula is actually two IF formulas in one…first, you have the first IF
formula IF(B7>C7,B7-C7,…). However, with the value_if_false part of the
equation, you include yet another IF formula: IF(C7>B7,C7-B7,”Tie”). If both
the first IF formula is false (meaning that B7 is NOT greater than C7) AND the
second IF formula is also false (C7 is NOT greater than B7), then the final false
value carries over from the second (or in this case, inner-most) IF formula,
which is “Tie.”

**Applying multiple conditions in a single formula

For this example, let’s say you wanted to determine if Player 2 had a good
game day by not only determining if Player 2 was a winner of the game, but
that they also scored more than 3 points. You can create an IF formula with a
nested AND formula so that you can narrow down your results to just the
games where Player 2 met BOTH criteria like so:

=IF(AND(D2=C1,C2>3),”Good Game”,”Needs Improvement”)

In this formula, if Player 2 (cell C1) is the victor (cell D2) of the game, AND
Player 2’s score (cell C2) is greater than 3, then a result of “Good Game” is
produced, otherwise it will result in “Needs Improvement.” This means that if
Player 1 wins, if there is a tie, or if Player 2 wins but doesn’t score more than 3
points, it will result in a “Needs Improvement” result. If you wanted to adjust
the formula so that if Player 2 scores 3 points and you want a “Good Game”
result instead of “Needs Improvement,” then you would adjust the > symbol to
a greater than or equal to symbol >= in the formula.

=IF(AND(D2=C1,C2>=3),”Good Game”,”Needs Improvement”)

**Conditional formatting

Formatting cells based on multiple criteria outside of the standard function

With Excel 2007, 2010 & 2013’s conditional formatting, you have several
options available that you can use to highlight the cells that you apply the
formatting to based on the selected cells’ value. But what if you wanted to
format cells based on criteria that is out of the scope of the default options?
You do it with a formula, of course!

In the Conditional Formatting menu, you can select the “Use a formula to
determine which cells to format” rule type, which will provide you with a box
for entering your formula. If, for instance, you wanted to highlight the cell
listing the Game number (i.e. cells A2:A5) based on the values of the cells in an
adjacent column (column D in this case which lists who the victor was), you
could use a formula such as:

=IF($D2=”Player 2″,TRUE,FALSE)

=AND(MONTH(C2)=MONTH(TODAY()),D2=”Sales”)
Keep in mind that by default, if you click on the cell you are using in the
formula, Excel will create an absolute reference (using $ in front of the column
letter and row number). If you want your formula to adjust along with the cells
that it applies to, you will need to remove these absolute references by simply
removing the $ accordingly). Once you’ve got your formula nice and spiffed up,
click on the Format button to designate the formatting you wish to apply (I’ve
chosen the cell fill color of blue), then hit OK.

Since I only applied this formatting to cell A2, I want to adjust the range of this
conditional format, so I will go to the Conditional Formatting menu, and under
Manage Rules, I can “stretch out” the range of this condition. Also, if I wanted
to apply another conditional format, say to highlight the games that Player 1
had won but in a different color, you can create a new rule with a new format
by following the same steps you did before, but adjusting the formula
to =IF($D2=”Player 1″,TRUE,FALSE) and changing the cell fill color (I chose
red).

You can repeat the same steps to highlight the cells that have a tie (I used a
purple cell fill color) with this formula in a new rule:

=IF($D2=”Tie”,TRUE,FALSE)

Make sure to adjust the ranges for the conditional formatting rules and you’ve
got a color coded list that adjusts when the scores change.

Using logical functions in Excel: AND, OR, XOR and NOT


Excel logical functions - overview

Microsoft Excel provides 4 logical functions to work with the logical values. The
functions are AND, OR, XOR and NOT. You use these functions when you want
to carry out more than one comparison in your formula or test multiple
conditions instead of just one. As well as logical operators, Excel logical
functions return either TRUE or FALSE when their arguments are evaluated.
The following table provides a short summary of what each logical function
does to help you choose the right formula for a specific task.

Formula
Function Description Formula Description
Example

The formula returns


=AND(A2>=10, TRUE if a value in cell
Returns TRUE if all
B2<5 A2 is greater than or
AND of the arguments
equal to 10, and a value
evaluate to TRUE.
) in B2 is less than 5,
FALSE otherwise.

The formula returns


TRUE if A2 is greater
than or equal to 10 or
Returns TRUE if any
=OR(A2>=10, B2 is less than 5, or
OR argument
B2<5) both conditions are
evaluates to TRUE.
met. If neither of the
conditions it met, the
formula returns FALSE.

The formula returns


TRUE if either A2 is
greater than or equal to
Returns a logical 10 or B2 is less than 5. If
=XOR(A2>=10,
XOR Exclusive Or of all neither of the
B2<5)
arguments. conditions is met or
both conditions are
met, the formula
returns FALSE.

NOT Returns the =NOT(A2>=10) The formula returns


reversed logical FALSE if a value in cell
value of its A1 is greater than or
argument. I.e. If equal to 10; TRUE
Formula
Function Description Formula Description
Example

the argument is
FALSE, then TRUE is
otherwise.
returned and vice
versa.

In additions to the four logical functions outlined above, Microsoft Excel


provides 3 "conditional" functions - IF, IFERROR and IFNA.

Excel logical functions - facts and figures


1. In arguments of the logical functions, you can use cell references, numeric
and text values, Boolean values, comparison operators, and other Excel
functions. However, all arguments must evaluate to the Boolean values of
TRUE or FALSE, or references or arrays containing logical values.
2. If an argument of a logical function contains any empty cells, such values
are ignored. If all of the arguments are empty cells, the formula returns
#VALUE! error.
3. If an argument of a logical function contains numbers, then zero evaluates
to FALSE, and all other numbers including negative numbers evaluate to
TRUE. For example, if cells A1:A5 contain numbers, the formula
=AND(A1:A5) will return TRUE if none of the cells contains 0, FALSE
otherwise.
4. A logical function returns the #VALUE! error if none of the arguments
evaluate to logical values.
5. A logical function returns the #NAME? error if you've misspell the function's
name or attempted to use the function in an earlier Excel version that does
not support it. For example, the XOR function can be used in Excel 2016 and
2013 only.
6. In Excel 2007 and higher, you can include up to 255 arguments in a logical
function, provided that the total length of the formula does not exceed
8,192 characters. In Excel 2003 and lower, you can supply up to 30
arguments and the total length of your formula shall not exceed 1,024
characters.
Using the AND function in Excel

The AND function is the most popular member of the logic functions family. It
comes in handy when you have to test several conditions and make sure that
all of them are met. Technically, the AND function tests the conditions you
specify and returns TRUE if all of the conditions evaluate to TRUE, FALSE
otherwise.

The syntax for the Excel AND function is as follows:

AND(logical1, [logical2], …)

Where logical is the condition you want to test that can evaluate to either
TRUE or FALSE. The first condition (logical1) is required, subsequent conditions
are optional.

And now, let's look at some formula examples that demonstrate how to use
the AND functions in Excel formulas.

Formula Description

=AND(A2="Bananas", Returns TRUE if A2 contains "Bananas" and B2


B2>C2) is greater than C2, FALSE otherwise.

Returns TRUE if B2 is greater than 20 and B2


=AND(B2>20, B2=C2)
is equal to C2, FALSE otherwise.

Returns TRUE if A2 contains "Bananas", B2 is


=AND(A2="Bananas",
greater than or equal to 30 and B2 is greater
B2>=30, B2>C2)
than C2, FALSE otherwise.
Excel AND function - common uses

By itself, the Excel AND function is not very exciting and has narrow usefulness.
But in combination with other Excel functions, AND can significantly extend the
capabilities of your worksheets.

One of the most common uses of the Excel AND function is found in the
logical_test argument of the IF function to test several conditions instead of
just one. For example, you can nest any of the AND functions above inside the
IF function and get a result similar to this:

=IF(AND(A2="Bananas", B2>C2), "Good", "Bad")

For more IF / AND formula examples, please check out his tutorial: Excel IF
function with multiple AND conditions.

An Excel formula for the BETWEEN condition

If you need to create a between formula in Excel that picks all values between
the given two values, a common approach is to use the IF function with AND in
the logical test.
For example, you have 3 values in columns A, B and C and you want to know if
a value in column A falls between B and C values. To make such a formula, all it
takes is the IF function with nested AND and a couple of comparison operators:

Formula to check if X is between Y and Z, inclusive:

=IF(AND(A2>=B2,A2<=C2),"Yes", "No")

Formula to check if X is between Y and Z, not inclusive:

=IF(AND(A2>B2, A2<C2),"Yes", "No")

As demonstrated in the screenshot above, the formula works perfectly for all
data types - numbers, dates and text values. When comparing text values, the
formula checks them character-by-character in the alphabetic order. For
example, it states that Apples in not between Apricot and Bananas because the
second "p" in Apples comes before "r" in Apricot.

As you see, the IF /AND formula is simple, fast and almost universal. I say
"almost" because it does not cover one scenario. The above formula implies
that a value in column B is smaller than in column C, i.e. column B always
contains the lower bound value and C - the upper bound value. This is the
reason why the formula returns "No" for row 6, where A6 has 12, B6 - 15 and
C6 - 3 as well as for row 8 where A8 is 24-Nov, B8 is 26-Dec and C8 is 21-Oct.
But what if you want your between formula to work correctly regardless of
where the lower-bound and upper-bound values reside? In this case, use the
Excel MEDIAN function that returns the median of the given numbers (i.e. the
number in the middle of a set of numbers).

So, if you replace AND in the logical test of the IF function with MEDIAN, the
formula will go like:

=IF(A2=MEDIAN(A2:C2),"Yes","No")

And you will get the following results:

As you see, the MEDIAN function works perfectly for numbers and dates, but
returns the #NUM! error for text values. Alas, no one is perfect : )

If you want a perfect Between formula that works for text values as well as for
numbers and dates, then you will have to construct a more complex logical
text using the AND / OR functions, like this:

=IF(OR(AND(A2>B2, A2<C2), AND(A2<B2, A2>C2)), "Yes", "No")


Using the OR function in Excel

As well as AND, the Excel OR function is a basic logical function that is used to
compare two values or statements. The difference is that the OR function
returns TRUE if at least one if the arguments evaluates to TRUE, and returns
FALSE if all arguments are FALSE. The OR function is available in all versions of
Excel 2016 - 2000.

The syntax of the Excel OR function is very similar to AND:

OR(logical1, [logical2], …)

Where logical is something you want to test that can be either TRUE or FALSE.
The first logical is required, additional conditions (up to 255 in modern Excel
versions) are optional.

And now, let's write down a few formulas for you to get a feel how the OR
function in Excel works.

Formula Description

=OR(A2="Bananas", Returns TRUE if A2 contains "Bananas" or


A2="Oranges") "Oranges", FALSE otherwise.

Returns TRUE if B2 is greater than or equal to


=OR(B2>=40, C2>=20) 40 or C2 is greater than or equal to 20, FALSE
otherwise.

Returns TRUE if either B2 or C2 is blank or


=OR(B2=" ", C2="")
both, FALSE otherwise.
As well as Excel AND function, OR is widely used to expand the usefulness of
other Excel functions that perform logical tests, e.g. the IF function. Here are
just a couple of examples:

IF function with nested OR

=IF(OR(B2>30, C2>20), "Good", "Bad")

The formula returns "Good" if a number in cell B3 is greater than 30 or the


number in C2 is greater than 20, "Bad" otherwise.

Excel AND / OR functions in one formula

Naturally, nothing prevents you from using both functions, AND & OR, in a
single formula if your business logic requires this. There can be infinite
variations of such formulas that boil down to the following basic patterns:

=AND(OR(Cond1, Cond2), Cond3)

=AND(OR(Cond1, Cond2), OR(Cond3, Cond4)

=OR(AND(Cond1, Cond2), Cond3)

=OR(AND(Cond1,Cond2), AND(Cond3,Cond4))

For example, if you wanted to know what consignments of bananas and


oranges are sold out, i.e. "In stock" number (column B) is equal to the "Sold"
number (column C), the following OR/AND formula could quickly show this to
you:
=OR(AND(A2="bananas", B2=C2), AND(A2="oranges", B2=C2))

OR function in Excel conditional formatting

=OR($B2="", $C2="")

The rule with the above OR formula highlights rows that contain an empty cell
either in column B or C, or in both.

Using the XOR function in Excel

In Excel 2013, Microsoft introduced the XOR function, which is a


logical Exclusive OR function. This term is definitely familiar to those of you
who have some knowledge of any programming language or computer science
in general. For those who don't, the concept of 'Exclusive Or' may be a bit
difficult to grasp at first, but hopefully the below explanation illustrated with
formula examples will help.

The syntax of the XOR function is identical to OR's :

XOR(logical1, [logical2],…)

The first logical statement (Logical 1) is required, additional logical values are
optional. You can test up to 254 conditions in one formula, and these can be
logical values, arrays, or references that evaluate to either TRUE or FALSE.

In the simplest version, an XOR formula contains just 2 logical statements and
returns:

 TRUE if either argument evaluates to TRUE.


 FALSE if both arguments are TRUE or neither is TRUE.

This might be easier to understand from the formula examples:

Formula Result Description

Returns TRUE because the 1st argument is


=XOR(1>0, 2<1) TRUE
TRUE and the 2nd argument is FALSE.

Returns FALSE because both arguments are


=XOR(1<0, 2<1) FALSE
FALSE.

Returns FALSE because both arguments are


=XOR(1>0, 2>1) FALSE
TRUE.

When more logical statements are added, the XOR function in Excel results in:

 TRUE if an odd number of the arguments evaluate to TRUE;


 FALSE if is the total number of TRUE statements is even, or if all statements are
FALSE.
The screenshot below illustrates the point:

If you are not sure how the Excel XOR function can be applied to a real-life
scenario, consider the following example. Suppose you have a table of
contestants and their results for the first 2 games. You want to know which of
the payers shall play the 3rd game based on the following conditions:

 Contestants who won Game 1 and Game 2 advance to the next round
automatically and don't have to play Game 3.
 Contestants who lost both first games are knocked out and don't play Game 3
either.
 Contestants who won either Game 1 or Game 2 shall play Game 3 to
determine who goes into the next round and who doesn't.

A simple XOR formula works exactly as we want:

=XOR(B2="Won", C2="Won")

And if you nest this XOR function into the logical test of the IF formula, you will
get even more sensible results:
=IF(XOR(B2="Won", C2="Won"), "Yes", "No")

Using the NOT function in Excel

The NOT function is one of the simplest Excel functions in terms of syntax:

NOT(logical)

You use the NOT function in Excel to reverse a value of its argument. In other
words, if logical evaluates to FALSE, the NOT function returns TRUE and vice
versa. For example, both of the below formulas return FALSE:

=NOT(TRUE)

=NOT(2*2=4)

Why would one want to get such ridiculous results? In some cases, you might
be more interested to know when a certain condition isn't met than when it is.
For example, when reviewing a list of attire, you may want to exclude some
color that does not suit you. I'm not particularly fond of black, so I go ahead
with this formula:

=NOT(C2="black")
As usual, in Microsoft Excel there is more than one way to do something, and
you can achieve the same result by using the Not equal to operator:
=C2<>"black".

If you want to test several conditions in a single formula, you can use NOT in
conjunctions with the AND or OR function. For example, if you wanted to
exclude black and white colors, the formula would go like:

=NOT(OR(C2="black", C2="white"))

And if you'd rather not have a black coat, while a black jacket or a back fur coat
may be considered, you should use NOT in combination with the Excel AND
function:

=NOT(AND(C2="black", B2="coat"))

Another common use of the NOT function in Excel is to reverse the behavior of
some other function. For instance, you can combine NOT and ISBLANK
functions to create the ISNOTBLANK formula that Microsoft Excel lacks.

As you know, the formula =ISBLANK(A2) returns TRUE of if the cell A2 is blank.
The NOT function can reverse this result to FALSE: =NOT(ISBLANK(A2))

And then, you can take a step further and create a nested IF statement with
the NOT / ISBLANK functions for a real-life task:

=IF(NOT(ISBLANK(C2)), C2*0.15, "No bonus :(")

Translated into plain English, the formula tells Excel to do the following. If the
cell C2 is not empty, multiply the number in C2 by 0.15, which gives the 15%
bonus to each salesman who has made any extra sales. If C2 is blank, the text
"No bonus :(" appears.
Lookup and reference functions (reference)

Function Description
ADDRESS function Returns a reference as text to a single cell in a worksheet
AREAS function Returns the number of areas in a reference
CHOOSE function Chooses a value from a list of values
CHOOSECOLS function Returns the specified columns from an array

CHOOSEROWS function Returns the specified rows from an array

COLUMN function Returns the column number of a reference


COLUMNS function Returns the number of columns in a reference
DROP function Excludes a specified number of rows or columns from the

start or end of an array


EXPAND function Expands or pads an array to specified row and column

dimensions
FILTER function Filters a range of data based on criteria you define

FORMULATEXT function Returns the formula at the given reference as text

GETPIVOTDATA function Returns data stored in a PivotTable report

HLOOKUP function Looks in the top row of an array and returns the value

of the indicated cell


HSTACK function Appends arrays horizontally and in sequence to return

a larger array
HYPERLINK function Creates a shortcut or jump that opens a document stored
Function Description

on a network server, an intranet, or the Internet


INDEX function Uses an index to choose a value from a reference

or array
INDIRECT function Returns a reference indicated by a text value
LOOKUP function Looks up values in a vector or array
MATCH function Looks up values in a reference or array
OFFSET function Returns a reference offset from a given reference
ROW function Returns the row number of a reference
ROWS function Returns the number of rows in a reference
RTD function Retrieves real-time data from a program that supports

COM automation
SORT function Sorts the contents of a range or array

SORTBY function Sorts the contents of a range or array based on the values

in a corresponding range or array

TAKE function Returns a specified number of contiguous rows or columns

from the start or end of an array


TOCOL function Returns the array in a single column

TOROW function Returns the array in a single row

TRANSPOSE function Returns the transpose of an array


UNIQUE function Returns a list of unique values in a list or range
Function Description
VSTACK function Appends arrays vertically and in sequence to return

a larger array
VLOOKUP function Looks in the first column of an array and moves across

the row to return the value of a cell


WRAPCOLS function Wraps the provided row or column of values by columns

after a specified number of elements


WRAPROWS function Wraps the provided row or column of values by rows

after a specified number of elements


XLOOKUP function Searches a range or an array and returns an item

corresponding to the first match it finds. If a match

doesn't exist, then XLOOKUP can return the closest

(approximate) match.
XMATCH function Returns the relative position of an item in an array or

range of cells.

What is the syntax for Match, Vlookup and INDEX?

Here is the syntax for these three very powerful functions in plain English:

What are vlookup () and match () ?


VLOOKUP and MATCH are your way of asking excel to find a needle in
haystack. Imagine you have all your customer contact information in one sheet
in the range A1:D5000 in the format phone number, name, city and date of birth.
Now you need to find out which customer has the phone number “936-174-
5910”. How do you do it?
You guessed it right, you use VLOOKUP and summon excel to do the search and
return with customer name.
While VLOOKUP is used to fetch value a based on what you are looking for,
MATCH is used to fetch the position of the value you are looking for.
See this illustration to understand :

What does VLOOKUP really do?

Imagine you have a list of data like this:


Now, how do you answer the question – “How many sales did Jimmy make?“
Yes, your guess is right. VLOOKUP is one of the formulas you can use to answer
questions like this.
VLOOKUP searches a list for a value in left most column and returns
corresponding value from adjacent columns.
So, in our case, we need VLOOKUP to search for Jimmy and return the amount of
sales he made from column 3.

VLOOKUP Syntax & Examples:

The syntax of VLOOKUP is simple:


=VLOOKUP( this value, your data table, column number, optional is your table
sorted?)
Here is an example to get you started:
VLOOKUP Examples & Homework

[NEW] XLOOKUP replaces VLOOKUP in Excel 365

If you are using Excel 365, you can use the new & improved XLOOKUP function. It
offers a shorter & more versatile syntax for performing lookups.
For ex: the same lookup as above will be done with XLOOKUP like below:
=XLOOKUP(“Jimmy”, A2:A14, C2:C14) will lookup “Jimmy” in column A and
return sales amount from Column C.

So what is INDEX() then?

INDEX function is your way of telling excel to fetch a value from large range of
values. Since MATCH() function can tell us where the data is found, you can then
use INDEX() function to extract corresponding data from another column. In this
case, we can use MATCH() to find out which row has net sales 1,799 and INDEX()
to return the name of the person. Like this:
Find the position of 1,799 in sales: =MATCH(1799, $C$2:$C$14, 0)
The answer will be 8.
To find the 8th person in names list, we can use INDEX() function like this:
=INDEX($A$2:$A$14, 8)
The answer will be Jagjit.
Related: Learn more about INDEX Formula.

So how are INDEX() and MATCH() linked to each other?


Since MATCH returns the position of the item you are looking for in a list, you can
then use this position in INDEX to fetch values surrounding the searched value.
So, we can combine both functions like this:
=INDEX($A$2:$A$14, MATCH(1799, $C$2:$C$14, 0))
This combination is called as INDEX+MATCH formulas.
Related: Using INDEX + MATCH functions & INDEX+MATCH Video

Finally

Remember, both VLOOKUP and MATCH throw a fail error of #N/A if the value
you are looking for is not there. If you want to stop seeing the error, use
IFERROR function.

Multiple Nested VLOOKUPs in Excel

Since you are here, I assume that you want to look up some values in multiple
tables. If any of the tables contains the given lookup value, you want to
retrieve them using Excel VLOOKUP function. Right? Here's how you do it.
Generic Formula for the nested VLOOKUP function
=IFERROR(VLOOKUP(lookup_value,table1,col,0),IFERROR(VLOOKUP(lookup_val
ue,table2,col,0),VLOOKUP(lookup_value,table3,col,0)))
lookup_value: This the value you are looking for in your record.
Table1, Tabl2, Table3,...: These are the tables in which you know that the
value exists.
col: The column number in the table from which you want to fetch the value.
0: This is for an exact match. If you want to do an approximate match use 1.
Let's have an example make things clear.
Using nested VLOOKUPs to search multiple tables
Let's create a scenario first. Assume that we run three Yoga classes. At the end
of the day, you find a wrist band that has the name John on it. Now you know
that John belongs to one of three classes. To lookup john in all three classes,
we will need to put nested or chained VLOOKUP function inside the IFERROR
functions.

Here, we want to lookup john using VLOOKUP in all three tables and fetch his
phone number.
Using the above generic formula, we put this formula in cell E12.
=IFERROR(VLOOKUP(D12,B2:C7,2,0),IFERROR(VLOOKUP(D12,F2:G7,2,0),VLOOK
UP(D12,J2:K7,2,0)))
Here, D12 is our lookup value.
B2:C7, F2:G7, and J2:K7 are the tables that we want to search in.
2 is the column number of tables from which we want to retrieve the number.
(Here column number is the same for every table, but it can be different in
different data sets).
When you hit the enter button, it retrieves john's number.

How does it work


The technique is simple. As we know that VLOOKUP throws #N/A error when it
fails to find the lookup value in the given table, and IFERROR function returns
specified value if it fed an #N/A error. We use these features in our advantage.
The first VLOOKUP runs. It fails to find John in the first table. It returns #N/A
error. Now, this function is encapsulated in the IFERROR function. Since the
first VLOOKUP formula has fed #N/A to IFERROR, the second part of IFERROR
runs, which again contains an IFERROR function.
In the next round, the VLOOKUP looks for john in the second table F2:G7. It
fails again and IFERROR bounces the control to the next part. In this part, we
only have VLOOKUP Function but this time it finds john in the third table J2:K7
and returns the number.
Note: In the above example, we were sure that John is part of one three
tables. But if you are not sure that your tables contain these values or not then
use another IFERROR function that tells return "Value not found in any table".
=IFERROR(VLOOKUP(D12,B2:C7,2,0),IFERROR(VLOOKUP(D12,F2:G7,2,0),IFERRO
R(VLOOKUP(D12,J2:K7,2,0),"Can't find")))

How to VLOOKUP between two sheets

For starters, let's investigate a simplest case - using VLOOKUP to copy data
from another worksheet. It's very similar to a regular VLOOKUP formula that
searches on the same worksheet. The difference is that you include the sheet
name in the table_array argument to tell your formula in which worksheet the
lookup range is located.

The generic formula to VLOOKUP from another sheet is as follows:

VLOOKUP(lookup_value, Sheet!range, col_index_num, [range_lookup])

As an example, let's pull the sales figures from Jan report to Summary sheet.
For this, we define the following arguments:

 Lookup_values are in column A on the Summary sheet, and we refer to the first
data cell, which is A2.
 Table_array is the range A2:B6 on the Jan sheet. To refer to it, prefix the range
reference with the sheet name followed by the exclamation point: Jan!
$A$2:$B$6.
Please pay attention that we lock the range with absolute cell references to
prevent it from changing when copying the formula to other cells.
Col_index_num is 2 because we want to copy a value from column B, which is
the 2nd column in the table array.

 Range_lookup is set to FALSE to look up an exact match.

Putting the arguments together, we get this formula:

=VLOOKUP(A2, Jan!$A$2:$B$6, 2, FALSE)

Drag the formula down the column and you will get this result:

In a similar manner, you can Vlookup data from the Feb and Mar sheets:

=VLOOKUP(A2, Feb!$A$2:$B$6, 2, FALSE)

=VLOOKUP(A2, Mar!$A$2:$B$6, 2, FALSE)

Tips and notes:

 If the sheet name contains spaces or non-alphabetical characters, it must be


enclosed in single quotation marks, like 'Jan Sales'!$A$2:$B$6.
 Instead of typing a sheet name directly in a formula, you can switch to the
lookup worksheet and select the range there. Excel will insert a reference with
the correct syntax automatically, sparing you the trouble to check the name
and troubleshoot.

Vlookup from a different workbook

To VLOOKUP between two workbooks, include the file name in square


brackets, followed by the sheet name and the exclamation point.

For example, to search for A2 value in the range A2:B6 on Jan sheet in
the Sales_reports.xlsx workbook, use this formula:

=VLOOKUP(A2, [Sales_reports.xlsx]Jan!$A$2:$B$6, 2, FALSE)

For full details, please see VLOOKUP from another workbook in Excel.

Vlookup across multiple sheets with IFERROR

When you need to look up between more than two sheets, the easiest solution
is to use VLOOKUP in combination with IFERROR. The idea is to nest several
IFERROR functions to check multiple worksheets one by one: if the first
VLOOKUP does not find a match on the first sheet, search in the next sheet,
and so on.

IFERROR(VLOOKUP(…), IFERROR(VLOOKUP(…), …, "Not found"))

To see how this approach works on real-life data, let's consider the following
example. Below is the Summary table that we want to populate with the item
names and amounts by looking up the order number in West and East sheets:

First, we are going to pull the items. For this, we instruct the VLOOKUP formula
to search for the order number in A2 on the East sheet and return the value
from column B (2nd column in table_array A2:C6). If an exact match is not
found, then search in the West sheet. If both Vlookups fail, return "Not found".

=IFERROR(VLOOKUP(A2, East!$A$2:$C$6, 2, FALSE), IFERROR(VLOOKUP(A2,


West!$A$2:$C$6, 2, FALSE), "Not found"))
To return the amount, simply change the column index number to 3:

=IFERROR(VLOOKUP(A2, East!$A$2:$C$6, 3, FALSE), IFERROR(VLOOKUP(A2,


West!$A$2:$C$6, 3, FALSE), "Not found"))

Tip. If needed, you can specify different table arrays for different VLOOKUP
functions. In this example, both lookup sheets have the same number of rows
(A2:C6), but your worksheets may be different in size.

Vlookup in multiple workbooks

To Vlookup between two or more workbooks, enclose the workbook name in


square brackets and put it before the sheet name. For example, here's how
you can Vlookup in two different files (Book1 and Book2) with a single
formula:

=IFERROR(VLOOKUP(A2, [Book1.xlsx]East!$A$2:$C$6, 2, FALSE),


IFERROR(VLOOKUP(A2, [Book2.xlsx]West!$A$2:$C$6, 2, FALSE),"Not found"))

Make column index number dynamic to Vlookup multiple columns

In situation when you need to return data from several columns,


making col_index_num dynamic could save you some time. There are a couple
of adjustments to be made:
 For the col_index_num argument, use the COLUMNS function that returns the
number of columns in a specified array: COLUMNS($A$1:B$1). (The row
coordinate does not really matter, it can be just any row.)
 In the lookup_value argument, lock the column reference with the $ sign ($A2),
so it remains fixed when copying the formula to other columns.

As the result, you get a kind of dynamic formula that extracts matching values
from different columns, depending on which column the formula is copied to:

=IFERROR(VLOOKUP($A2, East!$A$2:$C$6, COLUMNS($A$1:B$1), FALSE),


IFERROR(VLOOKUP($A2, West!$A$2:$C$6, COLUMNS($A$1:B$1), FALSE),
"Not found"))

When entered in column B, COLUMNS($A$1:B$1) evaluates to 2 telling


VLOOKUP to return a value from the 2nd column in the table array.

When copied to column C (i.e. you've dragged the formula from B2 to C2), B$1
changes to C$1 because the column reference is relative. Consequently,
COLUMNS($A$1:C$1) evaluates to 3 forcing VLOOKUP to return a value from
the 3rd column.

This formula works great for 2 - 3 lookup sheets. If you have more, repetitive
IFERRORs become too cumbersome. The next example demonstrates a bit
more complicated but a lot more elegant approach.
Vlookup multiple sheets with INDIRECT

One more way to Vlookup between multiple sheets in Excel is to use a


combination of VLOOKUP and INDIRECT functions. This method requires a little
preparation, but in the end, you will have a more compact formula to Vlookup
in any number of spreadsheets.

A generic formula to Vlookup across sheets is as follows:

VLOOKUP(lookup_value, INDIRECT("'"&INDEX(Lookup_sheets, MATCH(1, --


(COUNTIF(INDIRECT("'" & Lookup_sheets & "'!
lookup_range"), lookup_value)>0), 0)) & "'!table_array"), col_index_num,
FALSE)

Where:

 Lookup_sheets - a named range consisting of the lookup sheet names.


 Lookup_value - the value to search for.
 Lookup_range - the column range in the lookup sheets where to search for the
lookup value.
 Table_array - the data range in the lookup sheets.
 Col_index_num - the number of the column in the table array from which to
return a value.

For the formula to work correctly, please bear in mind the following caveats:

 It's an array formula, which must be completed by pressing Ctrl + Shift +


Enter keys together.
 All the sheets must have the same order of columns.
 As we use one table array for all lookup sheets, specify the largest range if
your sheets have different numbers of rows.

How to use the formula to Vlookup across sheets

To Vlookup multiple sheets at a time, carry out these steps:


1. Write down all the lookup sheet names somewhere in your workbook and

name that range (Lookup_sheets in our case).


2. Adjust the generic formula for your data. In this example, we'll be:
o searching for A2 value (lookup_value)
o in the range A2:A6 (lookup_range) in four worksheets
(East, North, South and West), and
o pull matching values from column B, which is column 2 (col_index_num) in
the data range A2:C6 (table_array).

With the above arguments, the formula takes this shape:

=VLOOKUP($A2, INDIRECT("'"&INDEX(Lookup_sheets, MATCH(1, --


(COUNTIF(INDIRECT("'"& Lookup_sheets&"'!$A$2:$A$6"), $A2)>0), 0)) &"'!
$A$2:$C$6"), 2, FALSE)

Please notice that we lock both ranges ($A$2:$A$6 and $A$2:$C$6)


with absolute cell references.

3. Enter the formula in the topmost cell (B2 in this example) and press Ctrl +
Shift + Enter to complete it.
4. Double click or drag the fill handle to copy the formula down the column.

As the result, we've got the formula to look up the order number in 4 sheets
and retrieve the corresponding item. If a specific order number is not found, a
#N/A error is displayed like in row 14:

To return the amount, simply replace 2 with 3 in the col_index_num argument


as amounts are in the 3rd column of the table array:

=VLOOKUP($A2, INDIRECT("'"&INDEX(Lookup_sheets, MATCH(1, --


(COUNTIF(INDIRECT("'" & Lookup_sheets & "'!$A$2:$A$6"), $A2)>0), 0)) & "'!
$A$2:$C$6"), 3, FALSE)

If you'd like to replace the standard #N/A error notation with your own text,
wrap the formula into the IFNA function:

=IFNA(VLOOKUP($A2, INDIRECT("'"&INDEX(Lookup_sheets, MATCH(1, --


(COUNTIF(INDIRECT("'" & Lookup_sheets & "'!$A$2:$A$6"), $A2)>0), 0)) & "'!
$A$2:$C$6"), 3, FALSE), "Not found")

Vlookup multiple sheets between workbooks

This generic formula (or its any variation) can also be used to Vlookup multiple
sheets in a different workbook. For this, concatenate the workbook name
inside INDIRECT like shown in the below formula:

=IFNA(VLOOKUP($A2, INDIRECT("'[Book1.xlsx]" & INDEX(Lookup_sheets,


MATCH(1, --(COUNTIF(INDIRECT("'[Book1.xlsx]" & Lookup_sheets & "'!
$A$2:$A$6"), $A2)>0), 0)) & "'!$A$2:$C$6"), 2, FALSE), "Not found")

Vlookup between sheets and return multiple columns

If you want to pull data from several columns, a multi-cell array formula can
do that in one go. To create such a formula, supply an array constant for
the col_index_num argument.
In this example, we wish to return the item names (column B) and amounts
(column C), which are the 2nd and 3rd columns in the table array, respectively.
So, the required array is {2,3}.

=VLOOKUP($A2, INDIRECT("'"&INDEX(Lookup_sheets, MATCH(1, --


(COUNTIF(INDIRECT("'"& Lookup_sheets &"'!$A$2:$C$6"), $A2)>0), 0)) &"'!
$A$2:$C$6"), {2,3}, FALSE)

To correctly enter the formula in multiple cells, this is what you need to do:

 In the first row, select all the cells to be populated (B2:C2 in our example).
 Type the formula and press Ctrl + Shift + Enter. This enters the same formula in
the selected cells, which will return a different value in each column.
 Drag down the formula to the remaining rows.

How this formula works

To better understand the logic, let's break down this basic formula to the
individual functions:

=VLOOKUP($A2, INDIRECT("'"&INDEX(Lookup_sheets, MATCH(1, --


(COUNTIF(INDIRECT("'"& Lookup_sheets&"'!$A$2:$A$6"), $A2)>0), 0)) &"'!
$A$2:$C$6"), 2, FALSE)

Working from the inside out, here's what the formula does:
COUNTIF and INDIRECT

In a nutshell, INDIRECT builds the references for all lookup sheets, and
COUNTIF counts the occurrences of the lookup value (A2) in each sheet:

--(COUNTIF( INDIRECT("'"&Lookup_sheets&"'!$A$2:$A$6"), $A2)>0)

In more detail:

First, you concatenate the range name (Lookup_sheets) and the range
reference ($A$2:$A$6), adding apostrophes and the exclamation point in the
right places to make an external reference, and feed the resulting text string to
the INDIRECT function to dynamically refer to the lookup sheets:

INDIRECT({"'East'!$A$2:$A$6"; "'South'!$A$2:$A$6"; "'North'!$A$2:$A$6";


"'West'!$A$2:$A$6"})

COUNTIF checks each cell in the range A2:A6 on each lookup sheet against the
value in A2 on the main sheet and returns the count of matches for each sheet.
In our dataset, the order number in A2 (101) is found in the West sheet, which
is 4th in the named range, so COUNTIF returns this array:

{0;0;0;1}

Next, you compare each element of the above array with 0:

--({0; 0; 0; 1}>0)

This yields an array of TRUE (greater than 0) and FALSE (equal to 0) values,
which you coerce to 1's and 0's by using a double unary (--), and get the
following array as the result:

{0; 0; 0; 1}

This operation is an extra precaution to handle a situation when a lookup sheet


contains several occurrences of the lookup value, in which case COUNTIF
would return a count greater than 1, while we want only 1's and 0's in the final
array (in a moment, you will understand why).

After all these transformations, our formula looks as follows:

VLOOKUP($A2, INDIRECT("'"&INDEX(Lookup_sheets, MATCH(1, {0;0;0;1}, 0))


&"'!$A$2:$C$6"), 2, FALSE)
VLOOKUP with Multiple Results

To lookup multiple matches with the VLOOKUP Function you need to create a
helper column within the table of data. The helper column uses the COUNTIF
Function to create a unique ID for each instance. The helper column must be
the leftmost column within the data set. If it’s not practical to adjust the data
set, you should look into the other method in the next section.

Let’s take a look at this method in practice:

Step 1:

Notice the formula in cell F6:


=B5&COUNTIF(B5:B$9,B5)

Specifically, the range referenced: B6:B$11 . Notice the $ Sign. The $ Sign
“locks” the cell reference: B$11. So as you copy the formula down, B$11 stays
locked. B6, however, is not locked, so as you copy the formula down B6 turns
into B7, etc. This technique, creates a unique number for each instance found.
The reason we leave B6 unlocked is so that as an instance is accounted for, it’s
removed from the total count, creating the unique number.

Also notice the &. & merges the Product Name with it’s instance number to
create one field that we will use in our lookup.
Step 2:

We’ve moved the new helper column (project_adj) to the left of the data set in
B14:C19. Now we can perform the VLOOKUP on multiple results. Instead of
searching for socks, search for socks1 and socks2. Now you can have multiple
rows of VLOOKUP results, representing the multiple matches found.

The downside to this method is you must edit the original data set (or
copy/paste the data set elsewhere) to perform the multiple results VLOOKUP.
Alternatively, you can use INDEX / MATCH Method:

INDEX / MATCH for Multiple Match Lookups

Most Excel users are aware of the power of the VLOOKUP Function, but many
are not aware of the power of the INDEX Function and the Match Function
used in combination. The INDEX / MATCH combination can be used to emulate
a VLOOKUP, with the advantage of more flexibility.
Note: The image directly below contains the formulas. The bottom image
contains the formula results.

What’s going on in the formulas above?

MATCH – Looks up a value’s position with a range. In this example, MATCH is


searching for “Socks” within the Product list.
INDIRECT – Creates a reference from a string of text. We use this to adjust the
Product list search array. Once a match is found, the range is adjusted to
exclude that match from the search, allowing the next match to be found. In
cell G5, we set the initial range to B5:B10 (by setting the initial start_num in
cell F5 to 5). In G5 we found a match in row 1 of the range, so F6’s start_num is
5+1=6.
INDEX – Returns a value from an array based on it’s column/row number
position in that array.

You might also like