Using a Simple Formula
A
formula helps you to calculate and analyze data on your worksheet. A
formula contains operands and operators as illustrated below.
F
a
+ b
ormula:
Operand
|
Example
|
Constant
value
|
2
|
Cell
reference
|
A1
|
Range
reference
|
A1:B2
|
Label
|
Jan
Sales
|
Range
name
|
Revenue
|
Function
|
Sum(A1:B4)
|
Operators:
|
Symbols
|
Addition
|
+
|
Subtraction
|
-
|
Multiplication
|
*
|
Division
|
/
|
Percent
|
%
|
Exponential
|
^
|
Microsoft
Excel formula syntax always starts with an equal
sign (=)
followed by the operands and the operators. The following are some
examples of formulas
=
2 + 3
= A1 - B6
= 3 * A5
= Sales / Months
= 5 ^ 4
The
order of the elements in a formula determines the final result of the
calculation. Excel performs the operations from left
to right
according to the order
of
operator
precedence.
Operator precedence
Operator
|
Description
|
:
(colon)
(single space)
, (comma)
|
Reference
operators
|
–
|
Negation
(as in –1)
|
%
|
Percent
|
^
|
Exponentiation
|
*
and /
|
Multiplication
and division
|
+
and –
|
Addition
and subtraction
|
&
|
Connects
two strings of text (concatenation)
|
=
< > <= >= <>
|
Comparison
|
For
example:
=
2 + 3 * 2
equals
8
Not
10
because Excel calculates multiplication before addition.
You
can control the order of calculation by using parentheses to group
operations that should be performed first.
For
example:
=
(2 + 3) * 2
equals
10
How To Resize The Formula Bar
SUMMARY
Click
the Expand Formula Bar
button at the right of the Formula Bar or position the mouse
pointer over the horizontal line under the Formula Bar.
Click
and drag to adjust the size of the Formula Bar.
|
TIPS
|
C
lick
the Expand
Formula Bar button at the right
of the formula bar.
The
formula bar expands to two rows. To collapse the Formula Bar,
click the Collapse Formula Bar button, as shown below. You can
also press <Ctrl>+<Shift>+<U> to expand and
collapse the Formula Bar.
Position
mouse pointer over the horizontal line under the Formula Bar.
The
mouse pointer changes to a double-headed arrow, as shown below.
Click
and drag to adjust the size of the Formula Bar.
This
method helps you to expand the Formula Bar to the size you
want.
|
How To Enter A Formula Using The Keyboard
SUMMARY
Click
the cell that you want to place the formula inside.
Type
= (equal sign) and the
formula.
Press
<Enter>.
|
|
Enter
the following data before you begin this task.
Click the cell
B5.
You
want to enter a formula in this cell.
Type
=B2+B3+B4.
The
formula always starts with = (equal sign) as illustrated below.
Press
<Enter>.
The
total is calculated. If you click at the cell B5, the formula
appears in the formula bar.
|
How To Enter A Cell or A Range Reference Using The Mouse
SUMMARY
Click
the cell in which you want to place the formula.
Type
= (equal sign) and use
the mouse to click the cell or range references.
Press
<Enter>.
|
|
Click the cell
B5.
You
will enter a formula in this cell.
Type
=,
click the cell
B2,
type +,
click the cell
B3,
type +,
click the cell
B4.
The
formula appears, as shown below.
Press
<Enter>.
The
total is calculated.
|
How To Use AutoSum To Calculate Totals
SUMMARY
Click
the cell in which you want to place the formula.
Click
the
AutoSum button.
Press
<Enter>.
|
|
Click the cell
B5.
You
will calculate the sum of the contents in the cells above the
active cell.
Click
the Formula
tab. In the Function
Library group, click the
AutoSum
button.
The
formula is created automatically. Excel adds the numbers above
the active cell. If no numbers are found above the active cell,
the numbers on the left of the active cell are added up. The
formula appears, as shown below.
Press
<Enter>.
The
total is calculated.
If
the active cell is not located at the bottom or on the right of
a list of numbers. You can still use the AutoSum button to
calculate the total.
-
1).
Click the cell and click the AutoSum
button. A formula appears, as shown on the right.
|
|
2)
Click to select the cells that contain the numbers you want
to add.
|
|
3)
Press <Enter>.
|
|
|
How To Use Relative References
SUMMARY
Click
the cell that contains the formula you want to copy.
Use
the AutoFill
or Copy & Paste
command to copy the formula to another cell.
|
TIPS
|
By
default, when a formula is created, references to cells or ranges
are based on their position relative to the cell that contains
the formula.
When
you copy the formula, Excel will automatically paste the adjusted
references in the destination cells relative to the position of
the formula.
Before
you begin, type in the data for Feb column, as shown below.
Click the cell
B5.
You
are going to copy the formula =SUM(B2:B4) in cell B5 to cell C5.
D
rag
the Fill
Handle to the right to fill the
cell
C5 with the formula.
The
Fill Handle is the small dot at the lower-right corner of the
active cell B5.
The
formula is copied from the cell B5 to cell C5.
Click
the cell
C5 to see the formula
=SUM(C2:C4).
The
range reference B2:B4 changes to C2:C4 when the formula is
copied to the right. Since you dragged the Fill handle to the
right, the column letter changes relatively to the right but row
number remains unchanged. The
destination cell contains references that are relative to the
source formula.
|
How To Use Absolute References
SUMMARY
Click
the cell that contains the formula.
Edit
the formula by adding dollar signs `$' to the cell
reference you want to set as an absolute reference.
|
|
Use
absolute references if you do not want Excel to adjust the
references in the formula when copying a formula to another cell.
Before
you begin, type in the Sales column and the Unit Price, as shown
below. The formula in cell C2 is =B2*B7.
When you copy the formula to cell C3 using AutoFill, the formula
changes from =B2*B7
to =B3*B8.
However, you do not want B7 to change to B8 because the unit
price is stored in cell B7. So, you need to set the cell
reference B7 as an absolute reference. To do this, add dollar
signs ($) in
the cell reference.
Click the cell
C2.
You
are going to copy the formula =B2*B7 to C3:C5.
Press
<Enter>. Click
the Fill
Handle at cell
C2 and drag to fill C3:C5.
This
is to find the sales for Mary, Steve and Total.
You
will get the wrong results as shown below.
Click
the cell
C3 to see the formula.
The
formula is =B3*B8,
which is a relative reference of =B2*B7 in cell C2. However,
the correct formula should be =B3*B7
instead.
|
TIPS
You
may press the <F4>
function key to apply $ to B7 instead of typing the dollar
sign ($) manually in the formula bar. Click on B7 in the
formula bar and press <F4>.
If
you press <F4> to apply $, it will first change B7 to
$B$7.
If you press <F4> again, it changes to B$7
and then to $B7
and finally back to B7.
$B
sets the column B to be absolute.
$7
sets the row 7 to be absolute.
|
|
C
lick
the cell
C2 again. Change the formula in
cell C2 by adding dollar signs ($) to the cell reference B7.
The new formula should be =B2*$B$7.
This
is to set the cell B7 as an absolute reference. You can change
the formula in the formula bar.
Click
and drag the Fill
handle down to cell
C5.
The
sales are recalculated.
Click
on cell C3, the formula is =B3*$B$7. The cell reference B7
(absolute reference) remains unchanged while cell reference B2
(relative reference) changes to B3.
|