microsoft excel

advertisement
MICROSOFT EXCEL
FORMULAS
Building Formulas ............................................................................................. 1
Writing a Formula .............................................................................................. 1
Parentheses in Formulas .................................................................................. 2
Operator Precedence ........................................................................................ 2
Changing the Operator Precedence .................................................................. 2
Functions .......................................................................................................... 3
The Insert Function Button ................................................................................ 3
The Function Arguments Box ............................................................................ 4
Correcting a Function ........................................................................................ 5
The Formula Ribbon ......................................................................................... 6
Round Number Functions ................................................................................. 7
IF Function ........................................................................................................ 8
IF Functions (Nested)........................................................................................ 9
LOOKUP Functions......................................................................................... 12
Special Paste as Values.................................................................................. 14
Roehampton University  May 2011
IT User Services
Building Formulas
Formulas are the heart and soul of a spreadsheet, and Microsoft Excel offers a rich environment in
which to build complex formulas. Armed with a few mathematical operators and rules for cell entry,
you can turn your worksheet into a powerful calculator.
Writing a Formula
1. Click in the cell where you want the answer to appear.
2. Type the equal sign <=> which will also appear in the formula bar. All formulas must begin with
the equal sign.
3. Do one of the following:


type in a numeric value
select a cell or a range of cells
4. A coloured border will appear on each cell that you select.
5. You can drag the line border to move the selection.
6. You can drag a corner handle to expand the
selection.
7. Use the number pad to type in the mathematic operators (add, subtract, divide, etc.).
8. Press the <ENTER> key when finished.
Example formula
What it does
=128+345
Adds 128 and 345
=5^2
Squares 5
=C2
Uses the value in the cell C2
=Sheet2!B2
Uses the value in cell B2 on Sheet2
=Asset-Liability
Subtracts a cell named Liability from a cell named Asset
1
Parentheses in Formulas
Formulas calculate values in a specific order. A formula in Excel always begins with an equal sign
<=>. Following the equal sign are the elements to be calculated (the operands), which are separated
by calculation operators (add, subtract, divide, etc.). Excel calculates the formula from left to right
according to a specific order for each operator in the formula.
Operator Precedence
If you combine several operators in a single formula, Excel performs the operations in the order as
listed in the following table:
Order of Excel Operations in Formulas (from first to last)
Operator
: (colon)
(single space)
, (comma)
%
^
* and /
+ and &
= < > <= >= <>
Description
reference operator
reference operator
reference operator
negation
percent
exponentiation
multiplication and division
addition and subtraction
concatenation of text strings
comparisons
If a formula contains operators with the same precedence, for example, if a formula contains both a
multiplication and division operator, Excel evaluates the operators from left to right.
Changing the Operator Precedence
To change the order of precedence, enclose in parentheses the part of the formula to be calculated
first. In the spreadsheet below, there are four different answers to identical formulas, as determined
by where the parentheses are placed.
2
Functions
A function is a predefined formula that operates on a value (or values) and returns a value (or
values). Many Excel functions are shorthand versions of frequently used formulas. All functions
consist of (1) a function name followed by (2) a set of arguments which are enclosed in parentheses.
The Insert Function Button
When you want to use an Excel function, you will need to open the Insert Function dialogue box.
1. Click in the cell where you want the answer to appear.
2. Click the Insert Function button in the formula bar.
3. Select the function you want from the Insert Function dialogue box.
4. You can search for a function or
select a category type from the
drop-down menu.
5. Use the scroll bar to view all the
functions in each category.
6. A brief description is given when
you click on a function.
3
The Function Arguments Box
1. When you select any function, the name and syntax
will appear in the formula bar.
2. The Function Arguments box will appear.
Name
Arguments
Result / Answer
Description
Statement
statement
3. As you click into each argument box, the “statement” will describe the required data.
4. Fill in the arguments, and then click the OK button.
5. The formula bar will also contain the
function in a “formula format”.
4
Correcting a Function
1. You can correct a function by clicking
and typing directly in the formula bar.
2. You can re-open the Function Arguments box by clicking on
the Insert Function button.
3. Click in any argument box that you want to change, and type your corrections.
4. If you enter a wrong expression in an argument box, the tag “Invalid” will appear.
5
The Formula Ribbon
1. You can access functions from the Formulas ribbon by using the Function Library group.
2. Next to each category name is an “arrowhead” sub-menu.
3. Select the function you want from the submenu or click on Insert Function to open the
Function Argument box.
4. If you type the first few letters of a function,
a “suggestion” list will appear, and then you
can select the function you want.
5. However, you must include the “equals”
<=> sign before you start typing the
function’s name.
6
Round Number Functions
There are various round numbers functions which allow you to round numbers:



to the nearest (or specified) decimal place(s)
to the nearest even or odd integer
to a specified ceiling or floor value.
Ceiling
up to the nearest integer or to the nearest multiply of significance
Even
a positive number up and a negative number down to the nearest even integer
Floor
down, toward zero, to the nearest multiply of significance
Int
M Round
Odd
Round
down to the nearest integer
returns a number rounded to the desired multiple
a positive number up and a negative number down to the nearest odd integer
returns a number rounded to a specified number of digits
Round Down
returns a number rounded down toward zero
Round Up
returns a number rounded up away from zero
1. The Number argument can be a number, a reference to a cell that contains a number, or a
formula that results in a number.
2. The Multiple argument (or Num-digits, Number, Significance as depends on which function) is
the number or decimal places you want to round to.
3. Below is a table of the results of different round functions:
7
IF Function
Use IF function to perform a logical test on a cell value. If it finds the test to be true, then Excel will
return whatever value, formula, or function you specify. And if it finds the test to be false, Excel will
return whatever value, formula, or function you specify.
1. Click in the cell where you want the answer to appear.
2. Click the Insert Function button in the formula bar.
3. Select the IF function from the Insert Function box.
4. Logical_test is any value or expression that can be evaluated as TRUE or FALSE.


For example, M3>68 is a logical expression.
The expression evaluates the value in cell M3 if it is greater than 68, and then returns either
a TRUE or FALSE result.
5. Value_if_true is the value that Excel enters on the spreadsheet if the Logical_test is TRUE.
This return value can be a number, a text string, a formula, or even another function. In the
example above, Excel will type the text <Pass>.
6. Value_if_false is the value that Excel enters on the spreadsheet if the Logical_test is FALSE.
This return value can be a number, a text string, a formula, or even another function. In the
example above, Excel will type the text <Fail>.
7. The formula bar will also contain
the function in a “formula format”.
8
IF Functions (Nested)
As a general rule of thumb, the arguments of functions will allow you to enter a number, a cell
reference, a formula, a text string, or indeed another function (which is called: nesting).
1. Open the IF function on the spreadsheet.
2. Enter the Logical_test expression as required.
3. Click in the Value_if_true argument.
4. From the Name box, click the arrowhead to open a sub-menu.
5. Select the IF function.
9
6. A new IF Function Arguments box will open, and will be nested in the Value_if_true argument.
Original IF
Value_if_true (nested) IF
7. Fill in the Value_if_true IF function as required. But do not click the OK button.
8. Rather than clicking the OK button, go to the formula syntax and select the “original” IF function.
9. This will open the first (original) IF function. You will see the second IF function nested in the
Value_if_true argument box.
10. Click in the Value_if_false argument box and repeat steps #4 and #5 as outlined on page 9.
10
11. Fill in the third Value_if_false IF function as required.
12. When finished, click the OK button.
13. The final formula syntax is illustrate below:
Original IF
Value_if_true (nested) IF
Value_if_false (nested) IF
14. To open any of the three IF Function Arguments boxes, select the IF in the formula
syntax, and then click on the Insert Function icon on the formula bar.
11
LOOKUP Functions
There are several functions that look up and return information that you have stored in a data table.
In the example of parking permits, we might wish to add a permit fee according to which college the
student is enrolled in.
1. Construct a data table to contain the required information.
2. Click in the cell where you want the answer to appear.
3. Click the Insert Function button in the formula bar.
4. Use the “HLOOKUP” function if the data table is stored horizontally across the columns. And use
the “VLOOKUP” function if the data table is stored vertically down the rows.
12
5. Lookup_value is the value to be found (to look up) in the first row of the data table.
6. Table_array is a table of information in which the lookup_value is found. Use a range reference
or a range name to designate the table. The values in the first row of table can be text, numbers,
or logical values.
7. Row_index_num is the row number in table_array from which the matching value will be
returned to the answer (or results) cell. A row_index_num of 1 returns the first row value in
table_array, a row_index_num of 2 returns the second row value in table_array, and so on.
8. Range_lookup is a logical value that specifies whether you want the LOOKUP function to find an
exact match or an approximate match. If you type in TRUE (or leave omitted), an approximate
match is returned. In other words, if an exact match is not found, the next largest value that is
less than lookup_value is returned. Therefore in the College Permit Fees Table a fee of 48 is
returned for a value of <T>.
This is because <T> (which is between the letters <S> and <W>) in the table array is “rounded
up” to the next largest value in the table which is <S>.
However, if you type in FALSE in the Range_lookup box, an exact match must be found. In the
illustration above, as there is no letter <T> in the table array, the error value <#N/A> is returned.
9. The final HLOOKUP syntax appears below in the formula bar.
13
Special Paste as Values
There may be reasons to “erase” the function and leave only the results in the cell as a “value”. In
the diagram below, the contents of cell <F3> is not the number 32, but the results of the HLOOKUP
function as seen in the formula bar.
1. Select the “answer” cells that display the results from the function.
2. Go to the Home ribbon and click the Copy icon from
the Clipboard group.
3. Next, click the arrowhead under the Paste icon, and
select the Paste Special option from the sub-menu.
4. In the Paste Special dialogue box, tick
the Values option, and then click the
OK button.
14

Further Help
IT Helpdesk
Library; Ground Floor
helpdesk@roehampton.ac.uk
Online Learning
24/7 Software Support
http://studentzone.roehampton.ac.uk/softwaresupport
Software Advisor
Daniel Rukstelis
d.rukstelis@roehampton.ac.uk
15
Download