Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
9 views

Excel Forms Funcs

This document discusses Excel formulas and functions. It covers the basics of formulas including operators, cell references, and functions. It also discusses entering formulas manually or by pointing, operator precedence, and referencing cells in other worksheets and workbooks.

Uploaded by

Shobhit Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Excel Forms Funcs

This document discusses Excel formulas and functions. It covers the basics of formulas including operators, cell references, and functions. It also discusses entering formulas manually or by pointing, operator precedence, and referencing cells in other worksheets and workbooks.

Uploaded by

Shobhit Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

FOR 240 Introduction to Computing in Natural Resources

7. Excel Formulas and Functions

7.1 Formulas

Formulas are what make a spreadsheet so useful. Without formulas, a spreadsheet


would be little more than a word processor with a very powerful table feature. A
worksheet without formulas is essentially dead. Using formulas adds life and lets you
calculate results from the data stored in the worksheet.

To add a formula to a worksheet, you enter it into a cell. You can delete, move, and
copy formulas just like any other item of data. Formulas use arithmetic operators to work
with values, text, worksheet functions, and other formulas to calculate a value in the cell.

A formula entered into a cell can consist of any of the following elements:

o Operators such as + (for addition) and * (for multiplication)


o Cell references (including named cells and ranges)
o Values or text
o Worksheet functions (such as SUM or AVERAGE)

Here are a few examples of formulas:

o =150*.05 Multiplies 150 times .05. This formula uses only values and isn’t all
that useful.
o =A1+A2 Adds the values in cells A1 and A2.
o =Income–Expenses Subtracts the cell named Expenses from the cell named
Income.
o =SUM(A1:A12) Adds the values in the range A1:A12.
o =A1=C12 Compares cell A1 with cell C12. If they are identical, the formula
returns TRUE; otherwise, it returns FALSE.

(1) Operators Used in Formulas

Excel lets you use a variety of operators in your formulas. The following is a list
of the operators that Excel recognizes. In addition to these, Excel has many built-in
functions that enable you to perform more operations.

Operator Name
+ Addition
- Subtraction
* Multiplication
/ Division
^ Exponentiation
& Concatenation
= Logical comparison (equal to)
> Logical comparison (greater than)

Excel Formulas and Functions, Provided by Jingxin Wang 1


FOR 240 Introduction to Computing in Natural Resources

< Logical comparison (less than)


>= Logical comparison (greater than or equal to)
<= Logical comparison (less than or equal to)
<> Logical comparison (not equal to)

The following are some additional examples of formulas that use various
operators.

=”Part-”&”23A” Joins (concatenates) the two text strings to produce Part-


23A.
=A1&A2 Concatenates the contents of cell A1 with cell A2.
Concatenation works with values as well as text. If cell A1
contains 123 and cell A2 contains 456, this formula would
return the value 123456.
=6^3 Raises 6 to the third power (216).
=216^(1/3) Returns the cube root of 216 (6).
=A1<A2 Returns TRUE if the value in cell A1 is less than the value
in cell A2. Otherwise, it returns FALSE. Logical
comparison operators also work with text. If A1 contained
Bill and A2 contained Julia, the formula would return
TRUE, because Bill comes before Julia in alphabetical
order.
=A1<=A2 Returns TRUE if the value in cell A1 is less than or equal
to the value in cell A2. Otherwise, it returns FALSE.
=A1<>A2 Returns TRUE if the value in cell A1 isn’t equal to the
value in cell A2. Otherwise, it returns FALSE.

(2) Operator precedence

You need to understand a concept called operator precedence, which basically is


the set of rules that Excel uses to perform its calculations. Table 1 lists Excel’s operator
precedence. This table shows that exponentiation has the highest precedence (that is, it’s
performed first), and logical comparisons have the lowest precedence.

Table 1. Operator precedence in Excel formulas.


Symbol Operator Precedence
^ Exponentiation 1
* Multiplication 2
/ Division 3
+ Addition 4
- Subtraction 5
& Concatenation 6
= Equal to 7
< Less than 8
> Greater than 9

Excel Formulas and Functions, Provided by Jingxin Wang 2


FOR 240 Introduction to Computing in Natural Resources

You use parentheses to override Excel’s built-in order of precedence. You can
also nest parentheses in formulas, which means putting parentheses inside of parentheses.
If you do so, Excel evaluates the most deeply nested expressions first and works its way
out.

(3) Entering formulas

As mentioned earlier, a formula must begin with an equal sign to inform Excel
that the cell contains a formula rather than text. Basically, two ways exist to enter a
formula into a cell: enter it manually or enter it by pointing to cell references.

Entering formulas manually:

You simply type an equal sign (=), followed by the formula. As you type, the
characters appear in the cell and in the formula bar. You can, of course, use all the normal
editing keys when entering a formula.

Entering formulas by pointing:

The other method of entering a formula still involves some manual typing, but
you can simply point to the cell references instead of entering them manually. For
example, to enter the formula =A1+A2 into cell A3, follow these steps:

(a) Move the cell pointer to cell A3.


(b) Type an equal sign (=) to begin the formula. Notice that Excel displays Enter
in the status bar.
(c) Press the up arrow twice. As you press this key, notice that Excel displays a
faint moving border around the cell and that the cell reference appears in cell
A3 and in the formula bar. Also notice that Excel displays Point in the status
bar.
(d) Type a plus sign (+). The faint border disappears and Enter reappears in the
status bar.
(e) Press the up arrow one more time. A2 is added to the formula.
(f) Press Enter to end the formula.

Pointing to cell addresses rather than entering them manually is usually more
accurate and less tedious.

Excel includes the Formula Palette feature that you can use when you enter or edit
formulas. To display the Formula Palette, click the Edit Formula button in the Formula
bar (the Edit Formula button looks like an equal sign). The Formula Palette lets you enter
formulas manually or use the pointing techniques described previously. The Formula
Palette, shown in Figure 1, displays the result of the formula as it’s being entered. The
Formula Palette usually appears directly below the edit line, but you can drag it to any
convenient location.

Excel Formulas and Functions, Provided by Jingxin Wang 3


FOR 240 Introduction to Computing in Natural Resources

Figure 1. Formula palette.

(4) Referencing cells outside the worksheet

Formulas can refer to cells in other worksheets —and the worksheets don’t even
have to be in the same workbook. Excel uses a special type of notation to handle these
types of references.

To use a reference to a cell in another worksheet in the same workbook, use the
following format:

SheetName!CellAddress

In other words, precede the cell address with the worksheet name, followed by an
exclamation point. Here’s an example of a formula that uses a cell on the Sheet2
worksheet:

=A1*Sheet2!A1 or =A1*’sheet name’!A1

This formula multiplies the value in cell A1 on the current worksheet by the value
in cell A1 on Sheet2.

To refer to a cell in a different workbook, use this format:

=[WorkbookName]SheetName!CellAddress

In this case, the workbook name (in square brackets), the worksheet name, and an
exclamation point precede the cell address. The following is an example of a formula that
uses a cell reference in the Sheet1 worksheet in a workbook named Budget:

=[Budget.xls]Sheet1!A1

If the workbook name in the reference includes one or more spaces, you must
enclose it (and the sheet name) in single quotation marks. For example, here’s a formula
that refers to a cell on Sheet1 in a workbook named Budget For 1999:

Excel Formulas and Functions, Provided by Jingxin Wang 4


FOR 240 Introduction to Computing in Natural Resources

=A1*’[Budget For 1999]Sheet1’!A1

When a formula refers to cells in a different workbook, the other workbook


doesn’t need to be open. If the workbook is closed, you must add the complete path to the
reference. Here’s an example:

=A1*’C:\ MSOffice\Excel\[Budget For 1999]Sheet1’!A1

(5) Absolute vs. relative references

You need to be able to distinguish between relative and absolute cell references.
By default, Excel creates relative cell references in formulas except when the formula
includes cells in different worksheets or workbooks. The distinction becomes apparent
when you copy a formula to another cell.

Relative References:

Figure 2 shows a worksheet with a formula in cell D3. The formula, which uses
the default relative references, is as follows:

=B3*C3*(1+B7)

When you copy this formula to the two cells below it, Excel doesn’t produce an
exact copy of the formula; rather, it generates these formulas:

o Cell D4: =B4*C4*(1+B8)


o Cell D5: =B5*C5*(1+B9)

Excel adjusts the cell references to refer to the cells that are relative to the new
formula. Think of it like this: The original formula contained instructions to multiply the
value two cells to the left by the value one cell to the left. When you copy the cell, these
instructions get copied, not the actual contents of the cell.

Figure 2. Copying formula.

Excel Formulas and Functions, Provided by Jingxin Wang 5


FOR 240 Introduction to Computing in Natural Resources

Absolute References:

Sometimes, however, you do want a cell reference to be copied verbatim. For


example, if we would like to multiply the fixed sale tax with each of three species, we
have to contain an absolute reference in the formula (Figure 3). In this example, cell B7
contains a sale tax rate. The formula in cell D3 is as follows:

=(B3*C3)*(1 + $B$7)

Notice that the reference to cell B7 has dollar signs preceding the column letter
and the row number. These dollar signs indicate to Excel that you want to use an absolute
cell reference. When you copy this formula to the two cells below, Excel generates the
following formulas:

o Cell D4: =(B4*C4)*(1+$B$7)


o Cell D5: =(B5*C5)*(1+$B$7)

In this case, the relative cell references were changed, but the reference to cell B7
wasn’t changed, because it’s an absolute reference.

Figure 3. Formula using absolute cell reference.

7.2 Functions

Functions, in essence, are built-in tools that you use in formulas. They can make
your formulas perform powerful feats and save you a lot of time. Functions can do the
following:

o Simplify your formulas


o Allow formulas to perform calculations that are otherwise impossible

Excel Formulas and Functions, Provided by Jingxin Wang 6


FOR 240 Introduction to Computing in Natural Resources

o Speed up some editing tasks


o Allow “conditional” execution of formulas —giving them rudimentary decision-
making capability

(1) Function examples

A built-in function can simplify a formula significantly. To calculate the average


of the values in ten cells (A1:A10) without using a function, you need to construct a
formula like this:

=(A1+A2+A3+A4+A5+A6+A7+A8+A9+A10)/10

Not very pretty, is it? Even worse, you would need to edit this formula if you
added another cell to the range. You can replace this formula with a much simpler one
that uses one of Excel’s built-in worksheet functions:

=AVERAGE(A1:A10)

What if you need to determine the largest value in a range? A formula can’t tell
you the answer without using a function. Here’s a simple formula that returns the largest
value in the range A1:D100:

=MAX(A1:D100)

Functions also can sometimes eliminate manual editing. Assume that you have a
worksheet that contains 1,000 names in cells A1:A1000, and all the names appear in all
capital letters. Your boss sees the listing and informs you that the names will be mail-
merged with a form letter and that all-uppercase is not acceptable; for example,
JOHN F. CRANE must appear as John F. Crane. You could spend the next several hours
reentering the list —or you could use a formula like the following, which uses a function
to convert the text in cell A1 to proper case:

=PROPER(A1)

Enter this formula once in cell B1 and then copy it down to the next 999 rows.
Then, select B1:B1000 and use the Edit -> Paste Special command (with the Values
option) to convert the formulas to values. Delete the original column, and you’ve just
accomplished several hours of work in less than a minute.

One last example should convince you of the power of functions. Suppose that
you have a worksheet that calculates sales commissions. If the salesperson sold more than
$100,000 of product, the commission rate is 7.5 percent; otherwise, the com-mission rate
is 5.0 percent. Without using a function, you would have to create two different formulas
and make sure that you use the correct formula for each sales amount. Here’s a formula
that uses the IF function to ensure that you calculate the correct commission, regardless
of the sales amount:

Excel Formulas and Functions, Provided by Jingxin Wang 7


FOR 240 Introduction to Computing in Natural Resources

=IF(A1<100000,A1*5%,A1*7.5%)

(2) Function arguments

In the preceding examples, you may have noticed that all the functions used
parentheses. The information inside the parentheses is called an argument. Functions
vary in how they use arguments. Depending on the function, a function may use:

o No arguments
o One argument
o A fixed number of arguments
o An indeterminate number of arguments
o Optional arguments

The RAND function, which returns a random number between 0 and 1, doesn’t
use an argument. Even if a function doesn’t use an argument, however, you must still
provide a set of empty parentheses, like this:

=RAND()
If a function uses more than one argument, you must separate each argument by a
comma. The examples at the beginning of the chapter used cell references for arguments.
Excel is quite flexible when it comes to function arguments, however. An argument can
consist of a cell reference, literal values, literal text strings, or expressions.

Using names as arguments:

As you’ve seen, functions can use cell or range references for their arguments.
When Excel calculates the formula, it simply uses the current contents of the cell or range
to perform its calculations. The SUM function returns the sum of its argument(s). To
calculate the sum of the values in A1:D20, you can use:

=SUM(A1:A20)

And, not surprisingly, if you’ve defined a name for A1:A20 (such as Sales), you
can use the name in place of the reference:

=SUM(Sales)

In some cases, you may find it useful to use an entire column or row as an
argument. For example, the formula that follows sums all values in column B:

=SUM(B:B)

This technique is particularly useful if the range that you’re summing changes (if
you’re continually adding new sales figures, for instance). If you do use an entire row or
column, just make sure that the row or column doesn’t contain extraneous information

Excel Formulas and Functions, Provided by Jingxin Wang 8


FOR 240 Introduction to Computing in Natural Resources

that you don’t want included in the sum. You might think that using such a large range (a
column consists of 65,536 cells) might slow down calculation time —this isn’t true.
Excel’s recalculation engine is quite efficient.

Literal arguments:

A literal argument is a value or text string that you enter into a function. For
example, the SQRT function takes one argument. In the following example, the formula
uses a literal value for the function’s argument:

=SQRT(225)

Using a literal argument with a simple function like this one defeats the purpose
of using a formula. This formula always returns the same value, so it could just as easily
be replaced with the value 15. Using literal arguments makes more sense with formulas
that use more than one argument. For example, the LEFT function (which takes two
arguments) returns characters from the beginning of its first argument; the second
argument specifies the number of characters. If cell A1 contains the text
Budget, the following formula returns the first letter, or B:

=LEFT(A1,1)

Expressions as arguments:

Excel also lets you use expressions as arguments. Think of an expression as a


formula within a formula. When Excel encounters an expression as a function’s
argument, it evaluates the expression and then uses the result as the argument’s value.
Here’s an example:

=SQRT((A1^2)+(A2^2))

This formula uses the SQRT function, and its single argument is the following
expression:

(A1^2)+(A2^2)

When Excel evaluates the formula, it starts by evaluating the expression in the
argument and then computes the square root of the result.

(3) Ways to enter a function

You have two ways available to enter a function into a formula: manually or by
using the Paste Function dialog box.

Entering a Function Manually

Excel Formulas and Functions, Provided by Jingxin Wang 9


FOR 240 Introduction to Computing in Natural Resources

If you’re familiar with a particular function —you know how many arguments it
takes and the types of arguments —you may choose simply to type the function and its
arguments into your formula. Often, this method is the most efficient.

If you omit the closing parenthesis, Excel adds it for you automatically. For
example, if you type =SUM(A1:C12 and press Enter, Excel corrects the formula by
adding the right parenthesis.

Pasting a Function:

Formula Palette assists you by providing a way to enter a function and its
arguments in a semi-automated manner. Using the Formula Palette ensures that the
function is spelled correctly and has the proper number of arguments in the correct order.
To insert a function, start by selecting the function from the Paste Function dialog
box, shown in Figure 4. You can open this dialog box by using any of the following
methods:

o Choose the Insert -> Function command from the menu


o Click the Paste Function button on the Standard toolbar
o Press Shift+F3

Figure 4. Paste function dialog box.

The Paste Function dialog box shows the Function category list on the left side of
the dialog box. When you select a category, the Function name list box displays the
functions in the selected category.

The Most Recently Used category lists the functions that you’ve used most
recently. The All category lists all the functions available across all categories. Use this
if you know a function’s name, but aren’t sure of its category.

When you locate the function that you want to use, click OK. Excel’s Formula
Palette appears, as in Figure 5, and the Name box changes to the Formula List box. Use
the Formula Palette to specify the arguments for the function. You can easily specify a
range argument by clicking the Collapse Dialog button (the icon at the right edge of each

Excel Formulas and Functions, Provided by Jingxin Wang 10


FOR 240 Introduction to Computing in Natural Resources

box in the Formula Palette). Excel temporarily collapses the Formula Palette to a thin
box, so that you can select a range in the worksheet.

When you want to redisplay the Formula Palette, click the button again.
The Formula Palette usually appears directly below the formula bar, but you can move it
to any other location by dragging it.

Figure 5. Formula palette.

7.3 Major Functions

(1) Mathematical functions

Excel provides 50 functions in this category, more than enough to do some


serious number crunching. The category includes common functions, such as SUM and
INT, as well as plenty of esoteric functions.

INT

The INT function returns the integer (non-decimal) portion of a number by


truncating all digits after the decimal point. The example that follows returns 412:

=INT(412.98)

RAND

The RAND function, which takes no arguments, returns a uniform random


number that is greater than or equal to 0 and less than 1. “Uniform” means that all
numbers have an equal chance of being generated. This function often is used in
worksheets, to simulate events that aren’t completely predictable —such as winning
lottery numbers —and returns a new result whenever Excel calculates the worksheet.
In the example that follows, the formula returns a random number between 0 and
12 (but 12 will never be generated):

=RAND()*12

Excel Formulas and Functions, Provided by Jingxin Wang 11


FOR 240 Introduction to Computing in Natural Resources

The following formula generates a random integer between two values. The cell
named Lower contains the lower bound, and the cell named Upper contains the upper
bound:
=INT((Upper-Lower+1)*RAND()+Lower)

ROUND

The ROUND function rounds a value to a specified digit to the left or right of the
decimal point. This function is often used to control the precision of your calculation.
ROUND takes two arguments: the first is the value to be rounded; the second is the digit.
If the second argument is negative, the rounding occurs to the left of the decimal point.
For example,

=ROUND(123.456, 0) = 123
=ROUND(123.456, 1) = 123.5
=ROUND(123.456, 2) = 123.46

SIN

The SIN function returns the sine of an angle. SIN takes one argument —the
angle expressed in radians. To convert degrees to radians, use the RADIANS function (a
DEGREES function also exists to do the opposite conversion). For example, if cell
F21 contains an angle expressed in degrees, the formula that follows returns the sine:

=SIN(RADIANS(F21))

SQRT

The SQRT function returns the square root of its argument. If the argument is
negative, this function returns an error. The example that follows returns 32:

=SQRT(1024)

To compute a cube root, raise the value to the 1 /3 power. The example that
follows returns the cube root of 32768 —which is 32. Other roots can be calculated in a
similar manner.

=32768^(1/3)

SUM

If you analyze a random sample of workbooks, you’ll likely discover that SUM is
the most widely used function. It’s also among the simplest. The SUM function takes
from 1 to 30 arguments. To calculate the sum of three ranges (A1:A10, C1:10, and

Excel Formulas and Functions, Provided by Jingxin Wang 12


FOR 240 Introduction to Computing in Natural Resources

E1:E10), you use three arguments, like this:

=SUM(A1:A10,C1:10,E1:E10)

The arguments don’t have to be all the same type. For example, you can mix and
match single cell references, range references, and literals, as follows:
=SUM(A1,C1:10,125)

SUMIF

The SUMIF function is useful for calculating conditional sums. SUMIF takes
three arguments. The first argument is the range that you’re using in the selection criteria.
The second argument is the selection criteria. The third argument is the range of values
to sum if the criteria are met. Suppose in a weekly timber production data set Column C
contains the end date of the week and Column M is the weekly production. If we would
like to sum this logger’s timber production in 1999, the following function can be used:

=SUMIF(C3:C136, "<31-dec-99",L3:L136) –
SUMIF(C3:C136, "<31-dec-98",L3:L136)

(2) Text functions

Although Excel is primarily known for its numerical prowess, it has 23 built-in
functions that are designed to manipulate text.

LEFT

The LEFT function returns a string of characters of a specified length from


another string, beginning at the leftmost position. This function uses two arguments. The
first argument is the string and the second argument (optional) is the number of
characters. If the second argument is omitted, Excel extracts the first character from the
text. In the example that follows, the formula returns the letter B:

=LEFT(“B.B. King”)

The formula that follows returns the string Alber:

=LEFT(“Albert King”,5)

LEN

The LEN function returns the number of characters in a string of text. For
example, the following formula returns 12:

=LEN(“Stratocaster”)

Excel Formulas and Functions, Provided by Jingxin Wang 13


FOR 240 Introduction to Computing in Natural Resources

If you don’t want to count leading or trailing spaces, use the LEN function with a
nested TRIM function. For example, if you want to know the number of characters in the
text in cell A1 without counting spaces, use this formula:

=LEN(TRIM(A1))

MID

The MID function returns characters from a text string. It takes three arguments.
The first argument is the text string. The second argument is the position at which you
want to begin extracting. The third argument is the number of characters that you want to
extract. If cell A1 contains the text Joe Louis Walker, the formula that follows returns
Louis:

=MID(A1,5,5)

REPLACE

The REPLACE function replaces characters with other characters. The first
argument is the text containing the string that you’re replacing. The second argument is
the character position at which you want to start replacing. The third argument is the
number of characters to replace. The fourth argument is the new text that will replace the
existing text. In the example that follows, the formula returns Albert Collins:

=REPLACE(“Albert King”,8,4, “Collins”)

UPPER

The UPPER function converts characters to uppercase.

=UPPER(A1)

Excel also has a LOWER function (to convert to lowercase) and a PROPER
function (to convert to proper case). In proper case, the first letter of each word is
capitalized.

(3) Logical functions

The Logical category contains only six functions (although several other functions could,
arguably, be placed in this category). This section discusses three of these functions: IF,
AND, and OR.

IF

The IF function is one of the most important of all functions. This function can
give your formulas decision-making capability.

Excel Formulas and Functions, Provided by Jingxin Wang 14


FOR 240 Introduction to Computing in Natural Resources

The IF function takes three arguments. The first argument is a logical test that
must return either TRUE or FALSE. The second argument is the result that you want the
formula to display if the first argument is TRUE. The third argument is the result that you
want the formula to display if the first argument is FALSE.

In the example that follows, the formula returns Positive if the value in cell A1 is
greater than zero, and returns Negative otherwise:

=IF(A1>0, “Positive”, “Negative”)

In our Christmas tree sale example, if B6 represents the sale amount, the
commission can be calculated as follows:

=IF(B6>=SalesGoal, B6*0.10, B6*0.05)

AND

The AND function returns a logical value (TRUE or FALSE) depending on the
logical value of its arguments. If all its arguments return TRUE, the AND function
returns TRUE. If at least one of its arguments returns FALSE, AND returns FALSE. In
the example that follows, the formula returns TRUE if the values in cells A1:A3 are all
negative:

=AND(A1<0,A2<0,A3<0)

The formula that follows uses the AND function as the first argument for an IF
function. If all three cells in A1:A3 are negative, this formula displays All Negative. If at
least one is not negative, the formula returns Not All Negative:

=IF(AND(A1<0,A2<0,A3<0), “All Negative”, “Not All Negative”)

OR

The OR function is similar to the AND function, but it returns TRUE if at least
one of its arguments is TRUE; otherwise, it returns FALSE. In the example that follows,
the formula returns TRUE if the value in any of the cells—A1, A2, or A3—is negative:

=OR(A1<0,A2<0,A3<0)

(4) Date and time functions

Excel has 14 date and time relate d functions that allow you to manipulate these
types of data.

TODAY

Excel Formulas and Functions, Provided by Jingxin Wang 15


FOR 240 Introduction to Computing in Natural Resources

The TODAY function takes no argument. It returns a date that corresponds to the
current date —that is, the date set in the system. If you enter the following formula into a
cell on January 5, 2003, the formula returns 1/5/2003:

=TODAY()

DATE

The DATE function displays a date based on its three arguments: year, month,
and day. This function is useful if you want to create a date based on information in your
worksheet. For example, if cell A1 contains 2003, cell B1 contains 1, and cell
C1 contains 4, the following formula returns 1/4/2003:

=DATE(A1,B1,C1)

DAY

The DAY function returns the day of the month for a date. If cell A1 contains the
date 1/5/2003, the following formula returns 5:

=DAY(A1)

TIME

The TIME function displays a time based on its three arguments: hour, minute,
and second. This function is useful if you want to create a time based on information in
your worksheet. For example, if cell A1 contains 10, cell B1 contains 25, and cell C1
contains 9, the following formula returns 10:25:09 AM:

=TIME(A1,B1,C1)

HOUR

The HOUR function returns the hour for a time. If cell A1 contains the time
10:25:09 AM, the following formula returns 10:

=HOUR(A1)

(5) Statistical functions

The Statistical category contains 80 functions that perform various calculations.


Many of these are quite specialized, but several are useful for non-statisticians.

Excel Formulas and Functions, Provided by Jingxin Wang 16


FOR 240 Introduction to Computing in Natural Resources

AVERAGE

The AVERAGE function returns the average (arithmetic mean) of a range of


values. The average is the sum of the range divided by the number of values in the
range.

The formula that follows returns the average of the values in the range A1:A100:

=AVERAGE(A1:A100)

If the range argument contains blanks or text, Excel doesn’t include these cells in
the average calculation. As with the SUM formula, you can supply any number of
arguments.

Excel also provides the MEDIAN function (which returns the middle-most value
in a range) and the MODE function (which returns the value that appears most frequently
in a range).

COUNTIF

The COUNTIF function is useful if you want to count the number of times that a specific
value occurs in a range. This function takes two arguments: the range that contains the
value to count and a criterion used to determine what to count. The COUNTIF function
is used in the formulas in column E. For example, the formula a cell below can count the
number of students with grade A.

=COUNTIF(B:B,A)

Notice that the first argument consists of a range reference for the entire column
B, enabling you to insert new names easily without having to change the formulas.

MAX and MIN

Use the MAX function to return the largest value in a range, and the MIN
function to return the smallest value in a range. Both MAX and MIN ignore logical
values and text. The following formula displays the largest and smallest values in a range
named Data; using the concatenation operator causes the result to appear in a single cell:

= “Smallest: “&MIN(Data)&” Largest: “&MAX(Data)

For example, if the values in Data range from 12 to 156, this formula returns
Smallest: 12 Largest: 156.

Excel Formulas and Functions, Provided by Jingxin Wang 17


FOR 240 Introduction to Computing in Natural Resources

Class Exercises

(1) Lab 3.

References

Walkenbach, J. 1999. Microsoft Excel 2000 Bible. IDG Books Worldwide, Inc. Foster
City, CA.

Excel Formulas and Functions, Provided by Jingxin Wang 18

You might also like