0% found this document useful (0 votes)
42 views28 pages

05 1022q Cell Formula Basics s2020

1. The document introduces cell formulas in Excel and covers basic arithmetic operations, functions, comparisons, and string operations. 2. Key topics include using arithmetic operators like addition and multiplication, functions like SUM and AVERAGE, comparing values with equals and not equals, and concatenating strings. 3. The presentation emphasizes order of operations in formulas, noting that exponents, multiplication/division, and addition/subtraction are evaluated in that order unless brackets are used.

Uploaded by

Peiang ZHAO
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
0% found this document useful (0 votes)
42 views28 pages

05 1022q Cell Formula Basics s2020

1. The document introduces cell formulas in Excel and covers basic arithmetic operations, functions, comparisons, and string operations. 2. Key topics include using arithmetic operators like addition and multiplication, functions like SUM and AVERAGE, comparing values with equals and not equals, and concatenating strings. 3. The presentation emphasizes order of operations in formulas, noting that exponents, multiplication/division, and addition/subtraction are evaluated in that order unless brackets are used.

Uploaded by

Peiang ZHAO
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/ 28

COMP1022Q

Introduction to Computing with Excel VBA

Cell Formula Basics

David Rossiter, Oz Lam and Gibson Lam


Outcomes
• After completing this presentation, you are
expected to be able to:
1. Understand the basics of using cell formulas
2. Write cell formulas using appropriate
operations and functions
3. Describe the expected results of some cell
formulas

COMP1022Q Cell Formula Basics Page 2


In This Presentation
• We will look at the following topics in this
presentation:
– Some basics of cell formulas
– Arithmetic + - * / ^
– Handling numbers • You are strongly
– Comparing things recommended to try out
the Excel files in the
– String concatenation COMP1022Q web site!
– String functions • See how the results of
the formulas change
– What goes first? when you change inputs
Cell Formulas
• Every formula starts with a =
• Here is a simple formula
calculating the average cost
of meals:
= SUM( B13:B17 ) / 5

• SUM is a
function • A range of • The total number
cells which of meals
contains the
costs of 5 • / means divide
meals
Arithmetic
• In cell formulas you can do basic
calculations like those you learned in
school:
+ Addition
- Subtraction
* Multiplication
/ Division
^ Power

COMP1022Q Cell Formula Basics Page 5


Arithmetic
• For example, if you want to add two
numbers 3 and 10, you do this:
= 3 + 10

• There are only 5 arithmetic operators + - * / ^


but there are also many functions (English words)
helping you perform other clever calculations
• For example, you can use
=AVERAGE(B13:B17)
to do the same thing as the formula shown before
Examples Of • These examples show the use of
Arithmetic + - * / ^ in cell formulas

This cell has the name A


This cell has the name B
Some Commonly Used Number Functions
• There are many functions that can be used in cell formulas
• Here we look at 7 common functions for handling numbers:
SUM for finding the total of a group of numbers
AVERAGE for finding the average of a group of numbers
STDEV for finding the standard deviation of a group of numbers
MAX for finding the maximum in a group of numbers
MIN for finding the minimum in a group of numbers
RANK for ranking a number in a group of numbers
COUNTIF for counting the number of occurrences of a value
• On the next slide we show an example which uses these
• Remember Ctrl ` can be used to show all the formulas
Example of Some Commonly Used Number Functions

• Take a look at the


example in the web site!
Here are the Formulas Used
Comparing Things
• Sometimes you need to know about the relationship
between two things
• For example, you might need to compare whether
two values are equal, or if they are different
• You can do that using these:

= equal to <> not equal to


< smaller than <= smaller than or equal to
> larger than >= larger than or equal to

COMP1022Q Cell Formula Basics Page 11


TRUE and FALSE
• The result of a comparison is
TRUE or FALSE
• In cells these are shown using capital letters
• For example, to test if the value in cell A4 is
larger than the value in cell B6, we can write
=A4 > B6
• The result won’t be a number; it will be either
TRUE or FALSE

COMP1022Q Cell Formula Basics Page 12


Examples Of • This example shows the most
Comparing Things basic ways to compare things

This cell has the name A


This cell has the name B
Comparing Things in COUNTIF
• We have seen COUNTIF helps us count the
number of occurrences of something, e.g.
=COUNTIF(J6:J16, "A")

• Instead of using an exact value we can do


something like =COUNTIF(B2:B6, "<40")
• This will count all the numbers less than 40

COMP1022Q Cell Formula Basics Page 14


• This extends a previous example
Example of • It counts the number of students who
Using COUNTIF failed a final exam, which had a pass
mark of 40

• Take a
look at the
example
in the web
site

"<40" means
any value
smaller than 40
Other Cell Functions with ‘IF’
• As well as COUNTIF(B2:B6, "<40") there’s
also these cell functions which have ‘if’ in their name:
• AVERAGEIF(B2:B6, "<40")
calculate the average for the cells which have values <40
• SUMIF(B2:B6, "<40")
add up the cells, for the cells which have values <40
• You can use any of these:
= equal to <> not equal to
< smaller than <= smaller than or equal to
> larger than >= larger than or equal to
String Concatenation
• In computer language, ‘a string’ means ‘a piece of text’
• Concatenate means putting one string at the end of
another string
• In Excel cell formulas, you can concatenate two strings
by using & or the CONCATENATE function
• For example, this formula:
="Happy" & "Birthday"
and this formula:
=CONCATENATE("Happy", "Birthday")
both produce the same result: HappyBirthday
String Concatenation
• Here is an example of both:

This cell has the name A


This cell has the name B

COMP1022Q Cell Formula Basics Page 18


String Concatenation and
the COUNTIF Comparison
• When you use COUNTIF with a comparison,
the comparison is written as a string, i.e.
COUNTIF(B2:B6, "<40")
• If you want to include a cell in the comparison,
you cannot write the cell reference directly
inside, i.e. COUNTIF(B2:B6, "<B8" )
• You will need to do this instead: Wrong!

COUNTIF(B2:B6, "<" & B8)


COMP1022Q Cell Formula Basics Page 19
Some Commonly Used String Functions
• There are many other functions for strings
• Here we look at some:
LEN Count the number of characters in a string
UPPER Convert all letters into upper case letters i.e. ABC
LOWER Convert all letters into lower case letters i.e. abc
LEFT Get the first few characters in a string
RIGHT Get the last few characters in a string
SUBSTITUTE Substitute (replace) some text in a string
• There are examples of these on the next slide

COMP1022Q Cell Formula Basics Page 20


Example of Some Commonly Used
String Functions

This cell has the name A


This cell has the name Old
This cell has the name New
What Goes First?
• If you enter the following formula
=5+2*3
you may think that the answer is 21
• However, Excel actually gives you the answer of 11
• That is because Excel thinks that multiplication is
more important than addition
• Therefore 2*3 is performed first, before the addition
• We say multiplication has a higher precedence than
addition

COMP1022Q Cell Formula Basics Page 22


Using Brackets
• Of course, if you use brackets that ensures that part
of a formula is evaluated first
• Examples:
=5+2*3 gives an answer of 11
=(5+2)*3 gives an answer of 21
• You might think you can always use brackets in
your cell formulas, so you don’t have to remember
which things are calculated first
• That’s true – until someone else gives you a formula
which doesn’t have any brackets in it…

COMP1022Q Cell Formula Basics Page 23


Precedence in Cell Formulas
• The following table shows you the different levels of
precedence, most important at the top:

^ Power
* and / Multiplication and division
+ and - Addition and subtraction
& String concatenation
= <> < <= > >= Comparisons
Precedence Example 1
= 20 - 10 / 2 * 3 + 2
• / and * have
higher precedence
than + and -, so
they are handled first
• / and * have equal • So the answer is:
precedence, so the =(20-((10/2)*3))+2
one on the left (/) is
evaluated first, then * = 7
• Then – and + are handled
• – and + have equal precedence, so the
one on the left (-) is evaluated first, then +
Precedence Example 2
= 10 / 2 * 4 - 3 ^ 3
• ^ has a higher
precedence than the
• So the answer is:
others, so it is handled
first =((10/2)*4)-(3^3)
• / and * have equal
precedence, so the one on =((10/2)*4)- 27
the left (/) is evaluated
first, then the * = -7
• The – is handled last
Precedence Example 3

• The comparison
is done last
• The concatenation
is done next
• The multiplication
• For this situation the is done first
result of the formula is:
Quick List of Cell Things
We Looked At
•+ - * / ^
• LEN
• = < > <> <= >=
• UPPER
• SUM • COUNTIF • LOWER
• AVERAGE • AVERAGEIF • LEFT
• STDEV • SUMIF • RIGHT
• MAX • SUBSTITUTE
• MIN •&
• RANK • CONCATENATE

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy