Excel - Formulas
Excel - Formulas
SébastienBancquart,
21/10/2014
TABLE OF CONTENTS
1 The calculation formulas......................................................................................................3
1.1 The simple formulas
1.1.1 Excel as a calculator............................................................................................3
1.1.2 Modify an existing formula.........................................................................................3
1.1.3 Note on the decimal symbol
1.1.4 Display of results
1.2 Utlisaton cell references...........................................................................5
1.2.1 First attempts...................................................................................................................5
1.2.2 Circular reference
1.2.3 Copy of formulas, movement, insertton,…...................................................................6
1.2.4 Copying of formula............................................................................................................7
1.3 References relatves and absolutes..................................................................................8
1.3.1 A concrete example...........................................................................................................8
1.3.2 The solutionton: the symbol $...................................................................................................8
1.3.3 The four types of references
1.4 Audit the formulas.........................................................................................................9
1.4.1 Background and Dependent Search.....................................................................9
1.4.2 Evaluateton the formulas.................................................................10
1.4.3 Espions.............................................................................................................................12
1.5 Name cases
2 The functionstons..................................................................................................................14
Page 1 of 28
2.2 Fundton the date and time.....................................................................................17
2.2.1 bases
2.2.2 Functionstspecifics on dates......................................................................................18
2.2.3 Fundtspecifics related to the hours....................................................................................18
2.3 Foncttwe conditiontonnelles..........................................................................................19
2.3.1 Foncton SI........................................................................................................................19
2.3.2 Functionstnested SI
2.3.3 Fundtlogical ones...........................................................................................................20
2.3.4 Fundtwe are interceptington d’erreur............................................................................21
2.4 Fundtresearch center..............................................................................................22
2.4.1 ResearchV
2.4.2 ResearchH......................................................................................................................23
2.4.3 Limittons........................................................................................................................23
2.5 Fonctin mathematicstques..........................................................................................23
2.5.1 Functiontrounding
Page 2 of 28
1 THE CALCULATION FORMULAS
1.1 SIMPLE FORMULAS
To indicate to Excel that we want it to perform a calculation, we need to start the line with it.
by the symbol =. It is also possible to make it start the line with + or -.
Note that if you want to enter a text starting with one of these characters, Excel will
automatically try to interpret it as a formula, even if it has none
significance, which will cause errors. To avoid this behavior, you can do
start your text with an apostrophe.
Excel is capable of performing all common calculations. It follows the legal order of operations.
operators, namely:
( ) : parentheses take precedence over everything.1
: the power symbol.=4^3 will calculate 43, that is 4x4x4 = 64.
E: indicates scientific notation. 1.5E3 means 1.5 × 10.31500.
*, / : Multiplication and division.
Addition and subtraction
In case of doubt, operators of equal precedence are processed from left to right.
1
Note that one can use nested parentheses. Excel, like in mathematics, will calculate first
the content of the deepest parentheses. To create nested parentheses, use only
parentheses, and not, as in mathematics, brackets or braces. These symbols have a different
signification.
Page 3 of 28
You can also use the bar located above your Excel sheet, which
It is particularly useful for editing long formulas.
If you are working on VERY long formulas that do not fit on one line, you
You can still improve readability, thanks to the arrow that is at the end.
right of the editing bar.
A simple formula like =1/3 can give an unpleasant display. You can
however easily adjust how many digits after the decimal point you want to display. In
On the Home tab, you can click on the following two buttons: to increase
or decrease this number.
This setting does not affect the calculation results; it is just a display. The content of the box
is always the actual result, with the hidden figures.
If, for any reason, you want to use the rounded results in a calculation,
you can use the rounding function that we will study later, or change this
behavior in Excel options.2
Main menu / options / Advanced options / Calculation of this workbook / Define calculation with precision
2
Page 4 of 28
1.2 USE OF CELL REFERENCES
The benefit of working in a spreadsheet is the ability to perform calculations on data.
stored in the sheet.
1.2.1 FIRST TESTS
Enter value 3 in A1, 4 in A2.
In cell B1, type =A1+A2
Excel recognizes the boxes you have entered: it automatically colors the text and
frame the corresponding boxes in the same color. It's practical for orientation.
The framework is of course temporary: as soon as you leave box B1, it will
disappear.
Validate. The calculation is being carried out.
You can also create formulas using boxes that themselves contain
formulas.
Here, modifying the content of A1 will trigger the automatic recalculation of B1, and then that of C1.
3
If this is not the case, your Excel has switched to manual calculation mode. The option is disabled through the tab.
Formulas / Calculation Options / Automatic Calculation.
Page 5 of 28
1.2.2 CIRCULAR REFERENCE.
Erase everything4
Indeed, Excel cannot solve this calculation. A1 depends on C1, which depends on B1, which
depends on A1... It indicates to you that there is a problem. As long as this issue is not
eliminated, Excel will not perform ANY calculations related to these cells.
Page 6 of 28
Excel adapts to all the changes you can impose on it, without ever destroying.
your formulas. Provided, of course, that you do not delete the cells that
intervene in your formulas.
The simplest method: select the C2 box. In the bottom right corner of this
There is a small black square handle. Take this handle.5and slide it towards the
bas. Excel takes care of everything.
Page 7 of 28
1.3 RELATIVE AND ABSOLUTE REFERENCES
1.3.1 A CONCRETE EXAMPLE
Page 8 of 28
Modify the formula to =A4*(1+B$1). Copy the formula down the entire column. Check that
Everything is OK.
A tip: when editing the formula, the F4 key allows you to toggle between types.
the other
When working with complex formulas, the coloring of the cells is not always
sufficient to help us understand how a formula works, in particular
when we are not the author.
An interesting outlet is the search for backgrounds.
Let us place ourselves in the case studied in the chapter1.3.2Position yourself on square B4 and click, in
Page 9 of 28
The arrows directly indicate the cells involved in our formula. If these
cells also contain a formula, so a second click on the same button will me
give the antecedents of the antecedents.
When you have completed your audit, to erase the arrows: click on 'Delete'
arrows:
A variant is the function 'identify dependents', which is right next to it. Let's test it.
for example starting from cell B1:
Page 10 of 28
Report from C1 to C3
In D1 enter =C1+C2
Report from D1 to D2
Finally, in E1, enter =D1+D2. Phew!
It must contain the value 48. How did we arrive at this result?
Page 11 of 28
The Step Out key allows us to go up one level.
In another example, you can enter a formula of the type =3 + 5* 8 / 2 – 4^3 * 2 – 1 in order to
check the order of precedence of operators.
1.4.3 SPYING
An interesting last audit feature is the spy window. It can be utle.
when working on multiple tabs or large tables, to have permanently
under the eyes, the result of one or more precise formulas, wherever one is
is found in the binder.
This is the purpose of the "Spies Window" function. Open it from the Formulas tab.
Page 12 of 28
The 'Add a spy' button allows you to select a cell, the content of which will be
always visible in this folder. You can have as many spies as needed at the same time.
1.5 NAME BOXES
Which of the two following formulas is the most understandable?
A10*(1+$B$1)*(1-$A$2)
=A10*(1+VATRate)*(1-DiscountPercentage)
These two formulas, calculating a net price based on a gross price, are completely
identities. One of the two is just easier to read. How to create second formulas
by naming certain cells in our sheet.
The tool that allows us to do this is once again in the Formulas tab: it is
Make 'New':
Page 13 of 28
This window allows you to give a Name to a cell (which can be found in Refers to
a). This name will be valid in the indicated Zone. We can thus restrict if necessary.
the use of a name for a tab or for the entire workbook.
Comments are optional.
Once the name is defined, it can be used in formulas in place of the address of
cell.
It is a good habit to name the cells containing fixed values. The gain in
Legibility is generally not negligible.
Overall, it's a good idea to put these constants in cells.
rather than typing them in plain text in a formula.6
2 THE FUNCTIONS
It would be tedious and pointless to make an exhaustive list of all the available functions.
The Excel help file is there for that. We will just take a look at some of the most useful ones.
2.1 BASIC FUNCTIONS
2.1.1 THE SUM FUNCTION
In a new sheet, let's fill the first 5 rows of column A with some
numbers. We want to calculate the sum and place it in cell A6.
The first method would be to type this :=A1 + A2 + A3 + A4 + A5. It works. But
What do we do if we have several hundred cells to sum?
6
These numbers are called 'magic numbers in computer science'. At first glance, =A10 * 1.2 seems to be a
simpler formula to calculate VAT, for example. But what happens on the day when the rate changes? We need to
modify all the formulas in the calculation sheet, hence a source of errors. If you have a formula of the type
=A10 * (1 + VATRate), you just need to update the value in the VATRate cell and you're done.
Page 14 of 28
The solution is to make use of Excel's built-in functions.
The formula to type is :=sum(A1:A5)
Notice how Excel suggests various functions when you start typing.
It's very handy when you can't remember the exact spelling.
Likewise, once=sum(typed, Excel reminds you of the list of the function's parameters:
Here, it's simple: you need a number (the one called number1), and possibly others.
names, separated by ;. The brackets always indicate that the argument is optional.
We could thus have a sum of several ranges, such as for example
=sum(A1:A5;B1:B7)
2.1.2 DIFFERENT MODES OF FUNCTION ENTRY
The most immediate way to enter a function is to type its name, as we have
and you.
We can also, in the case of common functions, use the function 'sum'
automatic
You can also edit a function with the function editor (sic !). We access it
with the FX button located to the left of the editing line:
Page 15 of 28
From here, you can search with more or less ease (it is not the easiest tool)
efficace d’Excel…) la foncton qui vous intéresse. Vous pouvez aussi la sélectonner dans les
provided lists.
Below the list of functions, you have a short description of the selected function,
with the list of parameters. If the description is not clear, below you have
a blue link to online help. It is rather well designed and should provide you with the
necessary explanations.
Page 16 of 28
This one describes the function to you and allows you to edit each argument one by one.
The argument is described in detail. It is a very good entry point when you do not know.
not the syntax of a function.
Once your arguments are entered, press OK. The system writes the formula by itself.
Note that you can re-enter this assistant from existing formulas.
even if they were not created by this method. Edit your formula, put it
cursor between the parentheses and click the fx button again.
2.1.3 AVERAGE, PRODUCT,…
When one masters sums, other similar functions are available:
AVERAGE(): calculates the average of selected cells, and its variants:
GEOMETRIC.AVERAGE() (root nth you product of the terms) and
HARMONIC.AVERAGE()(inverse of the average of the inverses).
PRODUCT(): the product of all selected terms.
MIN(), MAX(): returns respectively the smallest and largest term of the series.
2.2 DATE AND TIME FUNCTIONS
2.2.1 BASES
Excel internally stores dates and times as numbers. This represents the
number of days since 1900.
It is therefore possible to perform calculations on dates and times.
For example, if A1 contains a date, =A1 + 1 gives the next day. =A1 + 1/24 adds a
hour.
Subtracting two dates gives the number of days/hours separating them.
Page 17 of 28
Technically, it is possible to multiply or divide a date by a number, or even
two dates between them. Excel will give you a result, which however will not be very
signification...
7
This who correspond also directly à the function =WEEKNUM.ISO(). Cf :
hthttp://fr.wikipedia.org/wiki/ISO_8601#Num%C3%A9ro_de_semaineThe standard implementation of Excel contains
an error, it is based on the first Tuesday and not the first Thursday.
Page 18 of 28
To add or subtract hours, minutes, seconds from a date, you just need to
souvenir
A day has 24 hours. An hour has 60 minutes and a minute has 60 seconds.
A day has 1440 minutes and 86400 seconds.
To add a second, you need to add 1/86400.
For example :=A1 + 3/24 + 8/1440 + 32/86400 adds 1 hour, 32 minutes and 8 seconds to the
date contained in cell A1.
It is regrettable that there is no function on Excel like in other programming languages.
simple du type AjouteHeure(1,32,8).
The objective of these functions is to be able to answer questions such as: 'the price of
The item costs €10. If the customer buys more than 5, they will only pay €8 each.
2.3.1 FUNCTIONS
In French, the question is: "If we have 5 objects or fewer, then the price equals the number"
of objects multiplied by 10. Otherwise, the price is equal to the number of objects multiplied by 8.
In Excel, we will use a function that allows us to make this choice automatically.
It is the function IF.
The syntax is as follows: :=IF(Condition; calculation if true; calculation if false)
An example: in A1, enter the value 3.
In B1, the following formula:
IF(A1 <= 5, A1 * 10, A1 * 8)
The result obtained is 30 (3 * 10, because 3 is less than 5).
In A1, type now 10. You should get 80 in B1.
different
Page 19 of 28
When comparing numbers or dates, the result is the one that is logically
waiting.
When comparing text, it is the alphabetical order, character by character, that
give the result.8
A curiosity: if we compare text to numbers, by convention, the text is always
higher than the figures.
Let's take a concrete example: We want to validate a number between 1 and 10. If this number
is less than 1 or greater than 10, we want the system to respond that the
The number is too large or too small. Otherwise, let him tell us OK.
In French: if the number is too small, display too small. Otherwise, if it is too large, display
too large, otherwise display OK
In Excel, with two IF statements:
Enter a number in A1
In B1, the following formula: =IF(A1 < 1, "TOO SMALL", IF(A1 > 10, "TOO LARGE", "OK"))
taking good care not to forget any parentheses and being careful with the punctuation.
Test with different values of A1
A variant: modify the formula so that the system returns 1 for numbers that are too
pets, 10 for the too big ones, and the number itself when in the range.
8
Thus, it is important to understand that 11 < 1001 is true, while "11" < "1001" is false! Similarly, 11
"11" is false.
Page 20 of 28
Here are the main logical functions available:
AND(): true if both conditions are true
OR(): true if at least one of the two conditions is true
XOR() : exclusive or : true if one of the two conditions is true and only one.
NON(): takes a single argument. Switches true for false and vice versa.
Complete data on Boolean algebra, which allows for easy manipulation of these
concepts are easily found on the internet.9Here are just the main tables to
to know10
Excel provides some useful test functions. These are the functions whose names start
by EST. They return TRUE or FALSE, and can therefore be used in a test in a
IF function
An example: type in A1 the following formula: =0/0. It obviously returns a
error.
In B1, for example, try this :=IF(ISERROR(A1),"Error","Correct calculation")
9
For example here:hthttp://en.wikipedia.org/wiki/Boolean_algebra_(logic)
Boolean algebra pros will see that two are missing, curiously absent from Excel. EQV, which is true
10
when both are true or both are false. Can be replaced by=NOT(OR(A1;A2)); and IMP, which is false
uniquement quand le premier terme est vrai et le second faux. Peut être remplacé par=OU(NON(A1) ;A2).
Page 21 of 28
2.4 SEARCH FUNCTIONS
These functions allow you to easily perform this kind of action: Returns the name of a
product knowing its code. They ask Excel to go through a table (which can
to be very tall) in order to find a very specific piece of data. Master these functions
allows finally to do without complex tools like Access when one has a database
simple data to build.
These functions come in two flavors: SearchVetSearchH depending on whether
search is conducted in the vertical or horizontal direction.
2.4.1 VLOOKUP
Let's start with a concrete example. Copy this table:
Explanation: the function asks Excel to search for the first argument (A11) in the
table given in the second argument (A2:B9). Once found, return the value
which is located on the same line, but in the column whose number is given by the third
argument (2).
The fourth argument (FALSE) indicates whether to accept an approximate value.
2.4.1.1 APPROXIMATE VALUE: FALSE
With this parameter, the code must match exactly what is found in the list.
This is the most instinctive behavior, and very often the one we would expect. However,
it is not the one defined by default by Excel. If you omit this argument, you
You will therefore not have the expected behavior!
Page 22 of 28
2.4.1.2 APPROXIMATE VALUE: TRUE
This parameter can be useful when the entered value is a numeric value.
for example, modify your formula to set this parameter to TRUE. And look for the value
4,5. You do not get an error.
The system will scan the array in search of the value closest to the value
sought after. However, this flexibility comes at a cost. The input data must
Absolutely must be arranged in ascending order, under penalty of returning information
Erroneous.
2.4.2 RESEARCH
The HLookup function works exactly like the VLookup function, with the
same parameters and the same limitations. Just swap the roles of the rows and the
columns: Research does its search horizontally instead of doing it
vertically.
2.4.3 LIMITATIONS
These two functions have one real flaw: when you select the source table, the
the column where the search is performed is always the first one. Thus, it is impossible with
SearchV to return results to the left of the search column. Same with
ResearchH, it is impossible to return results located above the line.
sought after.
2.5 MATHEMATICAL FUNCTIONS
The number of mathematical functions available in Excel is staggering. We are
we will limit ourselves to the most useful for chemists (spare us, for example the
hyperbolic trigonometry
2.5.1 ROUNDING FUNCTIONS
We have previously seen how to force the display of results with a certain
number of digits after the decimal point. We also saw that it was only about display, and
that the result of the calculation remained accurate.
Pour faire un vrai arrondi, nous pouvons utliser la fonctonARRONDI, qui prend deux
parameters.
The first is the value that must be rounded. This can be a numerical value,
reference to another cell, or a more or less complicated calculation.
The second parameter is the number of decimal places to keep.
We can verify that this is a true rounding :=ROUND(10/3, 2) * 3 does not give
10...
Page 23 of 28
To round to the nearest whole number, simply round to zero decimal places: =ROUND(10/3, 0)
It is also possible to round to the nearest ten (by indicating -1 digit after the decimal point), the
hundred (-2 digits...) or more.
The rounding is done to the nearest value, according to commonly accepted rules.
If necessary, it is possible to round down to the strictly lower value (function
=FLOOR(), same parameters) or higher (function=CEILING(), same).
There are two standard deviations: STDEV.P and STDEV.S13The difference between
the standard deviation hypothesis assumes that the values
Entries make up only a part of the elements of the population. Its value is therefore more
greater than Pearson's standard deviation.
12
And we recall the formula: logy(x) = ln(x)/ln(y)
13
Note that there is only one T in ECARTYPE...
Page 24 of 28
Specialists will find their happiness in formulas like F.TEST (gives the result
the Fisher test) or others.
In a more classic way, you also know that AVERAGE.MODE is available.
Attention for users of software in the English language: the dots become
commas and the points commas !!!
Page 25 of 28
2.7.3 SOME SPECIFIC FUNCTIONS
Some functions are specific to matrices.
For example: TRANSPOSE will transpose a table. Thus, a table of 4 rows by 3 columns.
columns will become a table of 3 rows and 4 columns. Almost to mix some
results from different sources, when they are not presented as we
would like...
For example: this formula calculates the average of the elements of an array, excluding the
null terms:
=AVERAGE(IF(A1:A10<>0, A1:A10))
A final example (from Excel 2013 Bible): displaying a calendar through a "simple"
formula:
Select B2:H2, and merge and center
Enter a date in this box
Select B4:H9 and enter this formula:
IF(MONTH(DATE(YEAR(B2),MONTH(B2),1))<>MONTH(DATE(YEAR(B2),MONTH(B2),1)-
(JOURSEM(DATE(YEAR(B2), MONTH(B2), 1))-1)+{0;1;2;3;4;5}*7+{1.2.3.4.5.6.7}-
1);"";DATE(YEAR(B2), MONTH(B2), 1-DAYOFWEEK(DATE(YEAR(B2), MONTH(B2), 1))-
1 + {0;1;2;3;4;5} * 7 + {1.2.3.4.5.6.7} - 1)) (phew !!!)
- Apply a custom format: j
Page 26 of 28
December-14
29 30 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29
3 ET AFTER?
3.1 OTHER FUNCTIONS: MICROSOFT HELP AND INTERNET
We have not covered the full range of Excel's functions, far from it.
For more information, it is possible, via the function assistant, to access the help of
Microsoft. This help is also available via the F1 key.
Microsoft's help is quite well designed. For each function, you will have a
complete description of the effect, the list of mandatory and optional parameters, along with their
description, and especially, concrete examples that are rather speaking.
The Internet is an almost inexhaustible source of information, provided you know where and
what to look for.
Among the links interesting, Notes:
htp://www.excel-pratwhat.com/fr/index_of_functionstons.phpwhich contains a dictionary of
all the functions of Excel, and also a tool to translate the functions into a
English version of the software, which can be useful.
Finally, the paper literature, although not delivered with the software for many years,
still exists. I keep a copy of the 'Excel Bible' in my office.
for those who need it.
3.2 RELATED FEATURES: PIVOT TABLES
Page 27 of 28
Page 28 of 28