100% found this document useful (5 votes)
1K views108 pages

Excel Formulas and Functions - For Complete Beginners, Step-By-Step Illustrated Guide To Master Formulas and Functions - William B. Skates

Uploaded by

Fahad Ghany
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
1K views108 pages

Excel Formulas and Functions - For Complete Beginners, Step-By-Step Illustrated Guide To Master Formulas and Functions - William B. Skates

Uploaded by

Fahad Ghany
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 108

Copyright © 2018 by William B.

Skates
All right reserved. No portion of this book may be reproduced, stored in
a retrieval system, or transmitted in any form or by any means –
electronic, mechanical, recording or otherwise – except for brief
quotation in printed reviews without the prior written permission of the
publisher or the author.

Table of Contents
INTRODUCTION
CHAPTER 1: WHAT ARE FORMULAS AND FUNCTIONS?

CHAPTER 2: TEXT FORMULAS

CHAPTER 3: COMPARISON FORMULAS

CHAPTER 4: OPERATORS
CHAPTER 5: ABSOLUTE VS RELATIVE CELL REFERENCES
CHAPTER 6: SUM

CHAPTER 7: IF

CHAPTER 8: AND

CHAPTER 9: LEN

CHAPTER 10: OR

CHAPTER 11: NOT


CHAPTER 12: XOR

CHAPTER 13: SUMIF AND SUMIFS

CHAPTER 14: COUNT AND COUNTA


CHAPTER 15: AVERAGEIF AND AVERAGEIFS

CHAPTER 16: LARGE AND SMALL

CHAPTER 17: COUNTIF AND COUNTIFS

CHAPTER 18: VLOOKUP


CHAPTER 19: HLOOKUP

CHAPTER 20: A FEW NOTES ABOUT PASTING, ORDERING AND FILTERING

CONCLUSION
Complementary Books
Introduction

Hello, there future Excel Programmers! Thanks for


viewing this book. This book has been designed to be
your go-to book for excel formulas and
functions. Spreadsheets have been with us for a long time. The best-
known and most widely used spreadsheet is Microsoft Excel. Excel is
easy to use for most daily number crunching tasks and it comes with
formulas and functions that perform a host of tasks. Tasks such as
summing, manipulating text, averaging, comparing, answering what if
questions…

Assuming you know the meaning of such basic spreadsheet terms, as


row, column, and cell, and you know how to do such basic operations
as copy and paste, this little book will introduce you to a number of the
formulas and functions of Excel. It will give you the ability and
confidence to use them successfully.
Chapter 1: What are formulas and
functions?
A formula is an expression used to calculate the value in a cell.

For example, here is a very simple problem where A2 contains 5.7 and
B2 contains 6.4. The task is to put the products of these two numbers in
into cell C2. See diagram below.

We can do this by selecting c2 and writing the very simple formula =


A2*B2 then pressing enter [it does not matter if you write a2*B2,
A2*b2 or a2*b2, as uppercase and lower case letters are treated the
same when referring to columns].

When this is done it leads to the value of the product appearing in the
cell C2. [The word 'TEXT' and the expression fx = A2*B2, which are
shown in the diagram appear automatically. You can ignore them.]
Another simple example is adding the contents of the cells A2, A3, A4,
and putting the results in A5.

Again, we select A5 and write = A2+A3+A4.

After we press enter the result is obtained and ends up in A5.


So far so good, but what if you needed to add the contents of 100 cells.
It would take a long time to write = A2+A3+A4+ A5…… +A100 +
A101 and you would probably make an error.

Fortunately, the creators of Excel anticipated many needs of users


decades ago and created functions. For this particular problem, we use
the sum function.
Select cell c102 and type, '= SUM(a2:a101) '[this is called the function
declaration].
then press enter and cell a102 has the sum, which in this case was 6086.

A function is a predefined formula, which performs calculations with


the contents of cells.
Parameters
You may notice in the expression, '=SUM(a2:a101)' the interesting
phrase a2:a101. This is the range of the function. The range of a
function is the set of cells on which it acts. The range of the SUM
function is called its parameter, as it can vary. We will have different
ranges to which the SUM function is applied.

There are a vast number of functions in Excel, which you will become
familiar with as you master the use of this amazing tool. This little book
will look at some of the more important functions.
Chapter 2: Text Formulas
The Excel TEXT formula or function is a most interesting one.

Date format
The Excel TEXT formula or function can be used to bring about
changes of date and number format. Here is an example, suppose we
wanted to change a column of dates in a certain format

and wish to change them into the form mm/dd/yyyy. In order to do this,
we use the Text function.
We can pick any column of 7 cells to put them in, so let's put them in
the column starting at a2. Select a2 and type the function declaration,'
=TEXT(b2,"mm/dd/yyyy") '
If you do this, Excel automatically offers you possible functions to
make your task easier. You are sensible to use them.
Once you filled the function in press enter and you will find the correct
expression in a2.
You can quickly fill in the rest of the column by using the 'handle' at the
side of a2.

Then drag down.

Currency
Another possible use of the TEXT function is to convert a column of
numbers
into currency format.

Note the first number is contained in e2. Suppose the new column will
start at f10. Select f10 and type the function declaration, ' =
TEXT(e2,"$##.##") '

Press enter.

Now use the handle and move down to get the remaining conversions.

TEXT can be used in many ways like the two examples shown.
If we look at the structure or syntax of the TEXT function through a
declaration, '=TEXT(e2,"$##.##")', we see the parameters of the
TEXT function are TEXT( value, format_text ). Value, as the contents
of cells, is values; format_text, as the function acts to change the format
of the value.
Chapter 3: Comparison Formulas

Sometimes you wish to compare two columns.

You test whether two specific cells match with the IF function [We will
say more about this later]. Begin a formula with =IF( and enter the two
cell locations, with = between them. Put in a comma then enter
relevant text, in quotes, to show if the cells match. Put in another
comma and then the relevant text, in quotes, if there is a non-match.

Now press Enter to complete the formula.


Use the handle to complete the comparison.
Chapter 4: Operators

Excel has operators in four categories. These are arithmetic operators,


comparison operators, text concatenation operators, and reference
operators.

The arithmetic operators are the usual +, -, × and ÷ operators except


that in Excel × is written as * and ÷ as/. There are two other important
arithmetic operators. These are % [percentage, which calculates a
percentage] and ^ [caret, this raises to powers. See below].

Press enter

The comparison operators are as they are in arithmetic and they are: >,
< , < , > , =, ≠, however Excel uses <= for < , >= for > and <> for ≠.

Text concatenation may be a new idea for some of you. There is only
one text concatenation operator and that is & [ampersand]. Here is how
it works, suppose you had the string [word], "nice" in a2 and "cat" in b2

then = a2 & b2 gives "nicecat".


All this operator does is join words or strings into one word or string.

Another type of operator, which may be new to you is the type referred
to as a reference operator. Here are the reference operators.
: is the colon operator and refers to all references in a range from one
cell to another including the endpoints.
Example. a2:a4 refers to a2, a3, and a4.
, is the comma operator and joins two ranges together. Here is an
example a2: a4, b2: b4 refers to a2, a3, a4, b2, b3, b4. It is the
equivalent in mathematics of the union operator [ ∪ ].

Finally, we have the single space operator. This is just an empty space.
It produces references to common cells and ranges.
Example. a2:a4 a3:a5 gives a3, a4. Obviously, a3 and a4 are the only
common cells of the ranges a2, a3, a4 and a3, a4, a5. It is the equivalent
in mathematics of the intersection operator [ ∩ ].

A very important consideration in constructing formulas is the


precedence or order of operators, in order to get the correct result. All
formulas begin with = and if you are dealing with numbers the order is
similar to the order of arithmetical operators as described by BEDMAS

[Brackets → Exponents → Division and

Multiplication → Addition and Subtraction] or PEMDAS

[Brackets → Exponents → Multiplication and Division

→ Addition and Subtraction] taught in high school.

Here is how the precedence of Excel operations works.

: [colon], single-space, , [comma], negation [as in -7], % [percentage], ^


[caret], * and/[neither is above the other], + and - /[neither is above the
other], & [ampersand], =, <,>,<=, >=,<> [comparison].
Chapter 5: Absolute vs Relative Cell
References

When you working with Excel, you must know about what is called
relative vs. absolute cell reference.
The problem is this: if you COPY A FORMULA containing cell
references, generally the CELL REFERENCES CHANGE!
The diagrams below illustrate this.

Now copy these three cells to a1,b1,c1 and look what happens.

These cell references are named "relative" cell references, as they


change relative to where the formula is copied.
Sometimes, you don't want cell references altering when a formula is
copied. If that is the case then you use what is called absolute cell
references. In order to use absolute cell references, you put a "$" before
the column letter if you want that to always remain the same. Similarly,
you put a "$" in front of the row number if you want that to remain the
same.
The following diagrams should help you grasp this very important idea.

In this diagram, we are using relative references. Now copy the cell C2
to D3.

Note how the cells have changed from A1 B3 and B1 C3.


Now let's do this using Absolute References.

The first diagram is as we got last time because "nice" is actually in the
cell A1 and "cat" is actually in B1. Now let's copy the cell C2 to D3, as
we did before

This time we got 'nicecat' instead of 'gooddog' because the reference


was to A1 and B1 exactly and not just to the two cells immediately to
the left of the cell we were copying.
When you create spreadsheets decide before copying a formula the cell
references that are relative and those that are absolute.
You will realize the absolute importance of these ideas when we look at
the VLOOKUP and HLOOKUP functions later.
Chapter 6: SUM
We had a look at the SUM function in chapter 1. If you have forgotten
this have another read. However, here is another look at this
extraordinary function.

This time, we're going to sum 3 columns of numbers.

In order to do this, we shall use the : and , operators discussed in the


last chapter. In D12, write,' =SUM(b2:b11,c2:c11, d2:d11) ' then press
enter. The sum of these numbers is 1754.
Chapter 7: IF
In many ways, the IF function is the most important function Excel has.
Earlier, we showed how it could be used for comparisons. Here is
another example of this. We are going to have two columns of numbers.
Using IF, a column to the right will have the word "CAT" if the number
in the left column is no less than the number in the right. If this
condition is not met, in other words, if the number in the left column is
less than the number in the right then we will get "DOG". Here are the
columns.
Into cell a2 type the function declaration,' = IF(b2>=c2,
"CAT","DOG") ' then press enter.

Now, you can use the 'handle' to complete the use of the function.
Now before leaving the IF function, we will consider another extremely
useful property of this extraordinary function:- NESTING. In this
context, nesting has nothing to do with birds. It is the ability of the IF
function to make itself one of the choices. Here is an example to show
this.

Example. We are given the following column of numbers.

Into C column beside the numbers in B column, there will be sentences


saying," Bi has a number with x digits." Thus by 188, there will be,
"188 has 3 digits. The next diagram will show how this is done using
the IF function.
Using the 'handles' solves the final part of the problem.
Structure or Syntax of IF
If we look at the structure or syntax of the IF function through a
declaration, ' = IF(b2>=c2, "CAT","DOG") ', we see the parameters
of the IF function are IF( logical test, result if TRUE, result if FALSE ).
Logical test, which is either TRUE or FALSE, as the contents of cells
are values; Result if TRUE; Result if FALSE.
Chapter 8: AND

Another widely used Excel function is the AND function. It is either


TRUE or FALSE depending on whether two conditions are both true or
not.

Here is an example, which illustrates this. We need to compare the sizes


of the numbers contained in the rows of this table using the AND
function.

Into cell C2 type the function declaration,' =AND(A2<50,B2<50)'

then press enter.


Now use the handle to complete the task

The only row, which had A and B cells both less than 50 was row 4.

Here is another example of the same type. Find the rows in which the C
and D cells are both less than 50 in the table below.
Into cell E2 type the function declaration, ' =AND(C2<50,D2<50) '
then press enter.
Now use the handle to complete the task.
In this case, only rows 3 and 10 had C and D cells where the number
was less than 50.
Structure or Syntax of AND
If we look at the structure or syntax of the AND function through a
declaration, ' =AND(C2<50, D2<50)', we see the parameters of the
AND function are AND( logical test, logical test). The parameters are
two logical tests, the combination of whose results give different
results.
Chapter 9: LEN
The LEN function is one of a large number of Excel functions, which
handle strings [words]. The LEN function has a very simple format =
LEN (string). The function returns the number of letters in a string,
which is often in a cell.

Here is an example. We have a column of names and need to write


beside it the number of letters in each of the names.
The input in cell B2 is = LEN [A2].

Now press enter. This action produces

Then we use the handle to produce


There are many string functions in Excel. With Excel string functions,
you can do all sorts of things, such as joining text from different cells to
make a new one string, removing parts of a string depending on their
position or surroundings, substitution into parts of a string, etc.
Sometimes, these functions are referred to as text functions. This
sometimes leads to confusion with the TEXT function, which we
looked at in Chapter 2 .

The LEN function is a string function, some other very important string
functions are the LEFT and Right Functions. The LEFT function gets a
substring that contains a given number of left characters from a string.
Similarly, the RIGHT function gets a substring that contains a given
number of right characters from a string.
The following example shows how the LEFT function works.

Example. There is a column of names from which we want the two


most left characters.
The input in cell B2 is = LEFT (A2,2).

Now press enter. This action produces

Then we use the handle to produce


The RIGHT function is used in an identical way.

The Upper Function is a simple function UPPER(string), which acts to


convert all letters or characters in a string to upper case.

Here is an example of its use, UPPER('cat') = CAT.


Here is the result of its use combined with the handle on a column of
names.

There are many more string functions in Excel but we will only look at
one more, which is the MID function.
The structure or syntax of the function is MID(string, number1,
number2).

What do these parameters mean?

The string is the string or word, which the function is acting on,
number1 is the number of the letter in the string that you start with and
number2 is the number of the letters in the string that you want, starting
with the letter at number1.

Let's take the word, 'ELEPHANT' and calculate MID('ELEPHANT', 2,


5). The letter at position 2 is L and the fifth letter after starting with L is
A, hence MID('ELEPHANT', 2, 5) = LEPHA.

Now let's use the MID function on a column of strings.


Chapter 10: OR
A widely used Excel function similar to the AND function is the OR
function. It is either TRUE or FALSE depending on whether one or
both of two conditions are true or not.

Here is an example, which illustrates this.

Example. Find the rows in which either the A and B cells are less than
50 in the table below.

Into cell C2 type the function declaration,' =OR(A2<50,B2<50)' then


then press enter.

Finally, complete the task by using the handle.


In this case, we get TRUE for rows 2, 4, 5, 6, 7 and 11, as either one or
both the A and B cells contain numbers, which are less than 50.
Structure or Syntax of OR
If we look at the structure or syntax of the OR function through a
declaration, ' =OR(A2<50, B2<50)', we see the parameters of the OR
function are OR( logical test, logical test). The parameters are two
logical tests, the combination of whose results give different results.
Chapter 11: NOT
The NOT function is an interesting one. It only has a meaningful result
if a cell has a data type called Booleans, which are either TRUE or
FALSE. The number 1 is regarded as TRUE and 0 as FALSE.
The function NOT gives a value of FALSE if the cell contains TRUE
and TRUE if the cell contains FALSE.
Here is an example. In the last chapter, we got the table.

Use the NOT function on column C.

Into cell D2 type the function declaration =NOT(C2)


then press enter.

Now finish the task by using the handle.

You may well ask what effect the NOT function has on cells, which
contain data apart from Boolean. The table below gives the results on
some such cells.

It would seem any number except 0 is considered TRUE. Text like 'cat'
is not recognized.

Only use the NOT function on Boolean data!


Chapter 12: XOR
A widely used Excel function similar to the OR function is the XOR
function. Like the OR function, it is either TRUE or FALSE depending
on whether one or both of two conditions are true or not. It is fussier
than OR, as it is TRUE only if one of the conditions is TRUE. If both
conditions are TRUE then the XOR function gives False.

Here is an Example. We want TRUE if only one of Family or First


name has a length less than 7.

Into cell J2 type the function declaration,' =XOR(LEN(H2)<7,


LEN(I2)<7) ' press enter then use the handle to get
The reason that 'Benton Jimmy' gives FALSE is that the lengths of both
'Benton' and 'Jimmy' are less than 7 and with XOR this will give
FALSE, whereas if we had used OR we would have got TRUE.
Structure or Syntax of XOR
We could look at the structure or syntax of the XOR function through a
declaration, ' =XOR(A2<50, B2<50)' in the same way that we did for
the AND and OR functions. If we do so, we see the parameters of the
XOR function are XOR( logical test, logical test). The parameters are
two logical tests; the combination of whose results give different
results.
NB
The XOR function is a new one that was not in versions of Excel prior
to 2013.
Chapter 13: SUMIF and SUMIFs
These functions are very similar to the SUM function except that they
include the ability to put criteria in the function declaration. The best
way to show this is with some examples.

Here is the first example. In the table of data below, we want to add all
grades less than 50, using the functions of Excel.

Quite clearly the sum required is 28 + 23 + 33 + 14 = 98. Let's get this


using Excel.

Into any cell, except those with the data, type the function declaration, '
=SUMIF(D2: D15,"<50", D2: D15) ' then press enter and you get 98.
Interestingly, as the range with the criterion < 50 is the same as the
range we're summing over, we don't need the second D2: D13.

We would get exactly the same result if the function declaration was, '
=SUMIF(D2:D15,"<50") '. Try it and see for yourself.

If the range with the criterion is different from the range we're summing
over this is not true.

Example. Find the sum of all grades of Female students.

Into any cell, except those with the data, type the function declaration, '
=SUMIF(C2:C14,"F",D2:D15) ' then press enter. This time the result is
334.
The only trouble with SUMIF is that it only allows one criterion. If you
want multiple criteria [plural of criterion] then you have to use
SUMIFS. Once again an example will show what this entails.

Example. Find the sum of the grades of males whose school is 'A'.

Into any cell, except those with the data, type the function declaration, '
=SUMIFS(E2:E15,C2:C15,"M", D2:D15,"A") ' then press enter. This
time the result is 259.

The declaration is,' =SUMIFS(sum range, criterion 1, criterion 2,


criterion 3,….)'. Sum range is always like E2: E15 and is the set you
want to add over, criteria are always like D2: D15, "A", where you have
a range where the criterion applies then a comma then the actual
criterion.

These two functions have a structure or syntax so that the parameters


are range and logical tests.
Chapter 14: COUNT and COUNTA
This chapter deals with two very simple functions: COUNT and
COUNTA. All the COUNT function does is count the cells in a range,
which contain numbers. The COUNTA function, however, counts all
non-empty cells.

Example. Count all the cells with numbers only in the cells below.

Into any cell, except those with the data, type the function declaration, '
=COUNT(M2: M9, N2: N9) ' then press enter. The result is 6, as there
six cells, which contain numbers.

Now let's use COUNTA. Into any cell, except those with the data, type
the function declaration, ' =COUNTA(M2: M9, N2: N9) ' then press
enter. The result is 15, as there fifteen cells, which contain numbers.
Note that the empty cell is not counted, either by COUNT or
COUNTA.

These two functions have a very simple structure or syntax. Their only
parameter is a range.
Chapter 15: AVERAGEIF and
AVERAGEIFs
The AVERAGEIF and AVERAGEIFS functions are very similar to the
SUMIF and SUMIFS functions.

Example. Suppose you wanted to find the average grade of the female
students in the table below.

Into any cell, except those with the data, type the function declaration, '
=AVERAGEIF(C2: C15, "F", E2: E15) ' then press enter. This time the
result is 55.666….
Generally, the declaration is, ' =AVERAGEIF(criterion range,
criterion, average_range) '. The meaning of average_range is the range
you're going to take the average of. AVERAGEIF is for situations
where there is only one criterion.

If you have multiple criteria then you must use AVERAGEIFS.

Example. Suppose you wanted to find the average grade of the male
students who went to school B from the table below.

Into any cell, except those with the data, type the function declaration, '
=AVERAGEIFS(E2:E15,C2:C15,"M", D2:D15,"B") ' then press enter.
This time the result is 60.25
Generally, the declaration is, ' =AVERAGEIFs(average_range,
criterion1 range, criterion1, criterion2 range, criterion2,) '. The meaning
of average_range is the range you're going to take the average of.
AVERAGEIFS is for situations where there is more than one criterion.
Chapter 16: LARGE and SMALL
The LARGE and SMALL functions are very easy to understand and
use. The declaration ' = LARGE(F1: G100, 3)' finds the third largest
number in the range F1: G100.

Example. Find the fifth largest number of the set in the cells below.

Into any cell, except those with the data, type the function declaration, '
=LARGE(J2: K8, 5) ' then press enter. The result is 78.

Example. Find the second smallest number of the set in the cells below.
Into any cell, except those with the data, type the function declaration, '
=SMALL(J2: J15, 2) ' then press enter. The result is 23.
Chapter 17: COUNTIF and
COUNTIFS

The COUNTIF and COUNTIFS functions are very similar to the


SUMIF and SUMIFS functions.

Example. Suppose you wanted to find female students were in the table
below.

Into any cell, except those with the data, type the function declaration, '
=COUNTIF(C2: C15, "F") ' then press enter. The result is 6

Generally, the declaration is, ' =COUNTIF(criterion range, criterion) '.


COUNTIF is for situations where there is only one criterion.

If you have multiple criteria then you must use COUNTIFS.

Example. Suppose you wanted to find the number of male students


who went to school B from the table below.

Into any cell, except those with the data, type the function declaration, '
=COUNTIFS(C2:C15,"M", D2:D15,"B") ' then press enter. This time
the result is 4.
Generally, the declaration is, ' =COUNTIFS( criterion1 range,
criterion1, criterion2 range, criterion2,….) '. COUNTIFS is for
situations where there is more than one criterion.
Chapter 18: VLOOKUP
The next two chapters deal with the VLOOKUP and HLOOKUP
functions. These are very useful but are often misunderstood.

We will need a number of examples to try and make this clear. Here is
the first example.
We have a table of grades from a school.
and we want to put the math grade beside each Family Name in the list
below.

This could be done by the extremely tedious procedure of copying from


the table of grades to this table. If we did this Martelil would have 50
beside him and so on. Fortunately, the creators of Excel foresaw this
problem and devised the LOOKUP functions.

Here is how this problem is solved using the VLOOKUP function.


Into I2 type, ' = VLOOKUP(H2,$A$2:$E$21, 5, FALSE) ' then press
enter. The result is the value 50.
We finish the procedure with the handles.

Obviously, VLOOKUP works, but what does each part of


VLOOKUP(H2,$A$2:$E$21, 5, FALSE) mean?
H2 is the cell whose corresponding math grade is going to be
looked up.
$A$2:$E$21 is the range of values from which we will look up
the math grade. Note the use of absolute references. This is
usually ESSENTIAL!
5 refers to the column in the range where we get math grades.
Column 1 is taken as the LOOKUP column. Its data must be in
ASCENDING order.
FALSE means we want an exact match between the names in our
list and in the column Family. If we had used TRUE then the
function would have been satisfied with an approximate match.

Finally, and these are extremely important:


1. The column we are looking for matches in must be the first
column in the range.
2. The first column must be put in ascending order.

If you don't know how to order data then make sure to read the last
chapter.

Now another example, which will hopefully help cement these ideas.

A company has 5 employees who are paid different hourly rates, as


shown below in a Sheet1 of a spreadsheet using the range A1: B6.
In order to pay these people, it is necessary to fill in the Hourly Rate in
the table below in Sheet2 of the same spreadsheet.

We will use the VLOOKUP function to do this.

Into C2 type, ' = VLOOKUP(A2,Sheet1!$A$2:$B$6, 2, FALSE) ' then


press enter. Sheet1! tells VLOOKUP to go to Sheet1 to find the range
$A$2:$B$6. The result is the value $35 then use the handle to complete
the table.

Before we began it was necessary to make sure that a check was made
that the data in the lookup column was in ascending order. As it was,
there was no problem.

We can easily calculate the week's pay of the employees by typing, '=
B2*C2', into D2 then pressing enter followed by the handle.
Before finishing this function, let us examine the last parameter, which
takes the value FALSE for an exact match and TRUE for an
approximate match.
Leave the function as it is but change Diane to Diana. The table below
shows what happens.

However, now change FALSE to TRUE in the function declaration, ' =


VLOOKUP(A2, Sheet1!$A$2:$B$6, 2, TRUE) ' and then press enter
followed by the handle.

VLOOKUP has assigned Cathy's hourly rate, probably because the


names Cathy and Diana have the same number of characters or letters.
Cathy and Diana are regarded as approximately equal.
Finally, we have a look at the syntax of the VLOOKUP function. As
usual, a declaration is very useful: ' = VLOOKUP(H2,$A$2:$E$21, 5,
FALSE) '.
The parameters in order are, a cell [where the value to be looked up is],
the range where the function looks, the number of the column where the
value is found and a Boolean value of TRUE or FALSE.
Chapter 19: HLOOKUP
VLOOKUP used data arranged vertically; HLOOKUP uses data
arranged horizontally.
How can data be arranged horizontally? Here is an example:

Here is how you could access this simple table using HLOOKUP. The
problem is to find the number of Honda cars in stock, using the
HLOOKUP function, and write it in the cell B6 to the right of the word
Honda in cell A6.

In cell B6, type the function declaration,' =HLOOKUP("Honda",A1:E3,


2, FALSE)' then press enter.

We get the same result if we have ' =HLOOKUP(A6, A1: E3, 2,


FALSE)'. The reason is that the word 'Honda' is contained in A6.

However, see what happens if have ' =HLOOKUP(A2, A1: E3, 2,


FALSE)'.

The reason is that the word 'Honda' is not contained in A2.


Now, see what happens if have ' =HLOOKUP("FORD", A1: E3, 2,
FALSE)'.

The reason is that the word 'Ford' is contained in the top row of the
table with 20 below it in row 2.

As with VLOOKUP, we need to examine the function declaration and


explain what is happening. Here is the original function declaration, '
=HLOOKUP("Honda", A1:E3, 2, FALSE)'.

HLOOKUP searches for the word Honda in the top row of the range
A1: E3. Once this is found, the 2 tells HLOOKUP to take the contents
of row 2, which is beneath Honda and put it in B6. The FALSE tells
HLOOKUP that there must be an exact match. An approximate match,
such as HINDA or HONDO would not be acceptable, whereas it might
for TRUE.

Finally, you may recall that VLOOKUP required the left column to be
in ascending order. For HLOOKUP, this is not necessary for a last
parameter value of FALSE. However, it is necessary that the top row of
the range be in ascending order if the last parameter is TRUE.

We have often finished chapters on functions with a paragraph about


structure or syntax. We will not dwell on structure or syntax. The
syntax is very similar to that for VLOOKUP. If you are interested then
see what was written in that chapter about this topic.
Chapter 20: A few notes about
Pasting, Ordering and Filtering
Usually, basic information such as this is covered early. However, the
notes about ordering are only vital when you use LOOKUP functions.
Pasting

Here is the result of multiplying two columns of numbers using the


declaration, '= A2*B2' then the handle.

Often having computed a column like this it might be useful to


eliminate one or both of the source columns but if you delete them this
is what happens.

To avoid this use Paste Values


after copying the original.

Now after deleting one the table of products is unaffected, as can be


seen by looking at the diagram above.
Ordering
As mentioned and emphasized in the chapter on VLOOKUP, it is
absolutely important that the first column is in ascending order. This is
all well and good but how is this done?

Suppose the range we are going to look up from is the table below.

and suppose the lookup is based on ID. You can see that the table has
been ordered by Family.
To order this range by ID is very easy.
Here are the steps, after you have selected the range A2: E11.
(1) Click on the DATA tab on your Excel Menu.

(2) Open the Sort & Filter window.


(3) Pick Custom Sort [I always use this except for trivial sorts]

(4) Click on Family

(5) Select ID and press OK.


The VLOOKUP function can now be used.
Further Ordering
Consider the following data set of student results from a high school.

We want the results of the female students only with a total over the
three subjects and the results put in descending order, with the highest
total at the top, down to the lowest.

First, let's get the totals.


Into H2, type the formula declaration, ' = E2 + F2 + G2' then press
equal. Once this is done use the handle to get the data set below.
Now select A1: H22 and go to Data.
Go to Sort & Filter and do a custom sort based on Gender. Here is what
you should have.
Now select the range A1: H14, which is the range with females and
copy this range [ ctrl-c in a PC or command-c in a Mac]. Paste in some
place, using a special paste with Values. The result is shown below.

Now we need to sort them via total in descending order. Once again
select the range and go to Sort and Filter.
Select Custom Sort and make sure you pick Total and Largest to
Smallest.
We now have the desired table.

Some of you may have wondered about Filter. What is this? Read on to
find out.
Filter
I will not spend too much time on this. Basically, it is a way of
examining a set of data using constraints but leaving the data set intact.

Here is an example. The data set below is the same one we extracted the
females from before using order. This time we are going to have a look
at the male results in ascending order of Total [smallest to largest], save
the filtered data set elsewhere then restore the data set.

Go to the Sort & Filter tab, as you did before, after clicking on the Data
tab of the Excel menu.
This time click Filter, but NOT the down arrow, after selecting the
whole data set.

You will notice little arrows. Click on the arrow in the Gender column.
Immediately you do, the following window appears.
Fill it in as shown.
Leading to
Finally, close the Gender window and you only have the Male results.

These results are in descending order. However, as it is necessary to put


them in ascending order, you use the little arrow beside Total. A little
window appears in which ascending is an option.

Clicking on this will put the results in ascending order.


If you want to save this as a data set then just select the set and paste it
somewhere. I have pasted it just below the filter. Notice that the data is
copied as Values.

Finally, restoring the original set of data is easy. Just click on the Filter
icon. When you do this the Filter arrows are removed and you have the
original data set restored.
Filtering by Color
While exploring Filter, you may have noticed the option Filter by Cell
Color.

Hitherto, this has been irrelevant, as we have only used Black and
White. However, Excel offers all sorts of color schemes. Two simple
ones for Fill Color and Font Color are shown.

To show the use of Filter by Cell Color, we have colored the data set
we have been using.
Now click on Filter after selecting the data set. This results in the
following.
Now use any little arrow, choose color and finally yellow or red.
If we pick red then we get the filter below.

We restore the original by clicking on the Filter icon.


Conclusion
Excel has a computer language called VBA [Visual Basic for
Applications] associated with it. Really good exponents of Excel use
VBA all the time

If you wish to master it you must know the basics of formulas and
functions inside and out.

This book has thoroughly covered many of those basics.

Before you proceed further with formulas and functions you must
master the material in the book to the extent that you can do the
problems in every chapter.

Once you have mastered the material in this book you are ready for all
the other things that can be done with EXCEL and the VBA
programming language!

Good Luck.

Welcome to the last page reader, I'm happy to see you here I hope you
had a great time reading my book and if you want to support my work,
leaving an honest review will be highly appreciated. Thank you so
much!

Respectfully,
William B. Skates

You might also like