C Functions
C Functions
To pass each student needs a grade of at least 5 and needs to be absent no more than 5 times. Use the IF function to fill colum
Use a combination of IF and AND to figure out for each student if they passed or not.
Use the IF function to fill columns D and E with ‘yes’ or ‘no’
testing
Example:
It’s possible to name cells and cell ranges. Then we can use the name as the cell reference instead of the column letter and row
- Name the cell B9 as ‘taxrate’
- Fill out cell C12 As ‘=B12*taxrate’
- Copy down the formula
- Name the range C12:C15 To ‘taxes’
- Insert the formula ‘=SUM(taxes)’
Exercise:
- Name the cell B24 ‘exchangerate’
- Use the cell name to calculate the ‘Value in MDL’
- Name the range C27:C36 ‘valuesMDL’
- Use the named range to calculate the average of ‘Value in MDL’
Average: 2033.13
04/25/2024 3
testing
04/25/2024 4
TextFunctions
Exercise: Combine the following columns to creat serial numbers (the first has been done as an example)
Lookup the functions LEFT, RIGHT, and MID and use them to answer the following questions
My uncle went fishing on a beautiful Sunday.
- Use LEFT to get the first 8 letters of the sentence in A14. My uncle
- Use RIGHT to get the last 7 letters of the sentence in A14. Sunday.
- Use MID to get 4 letters from the sentence, starting from the 15 th letter. fish
- Use UPPER to get the whole sentence in uppercase values. MY UNCLE WENT FISHING ON A BEAUTIFUL SUNDA
- Use LOWER to get the whole sentence in lowercase values. my uncle went fishing on a beautiful sunday.
- Use FIND to find the where word in B22 can be found in the sentence. 15
fishing
Page 5
TextFunctions
L SUNDAY.
y.
Page 6
DateAndTimeFunctions
The value in cell B4 is the 12th of March 2020, eleven past 3 pm, and 5 seconds.
Use the following functions to get the day, month, year, hour, minute, second and weekday.
12-Mar-2021 15:11:05
DAY 12
MONTH 3
YEAR 2021
HOUR 15
MINUTE 11
SECOND 5
WEEKDAY 6
Use WEEKDAY to complete column B in the following table. Then use conditional formatting to highlight the weekends.
(Hint: 1 = Sunday, 2 = Monday, 3 = Tuesday etc…)
Date Weekday
02-07-22 2
02-08-22 3
02-09-22 4
02-10-22 5
02-11-22 6
02-12-22 7
02-13-22 1
02-14-22 2
02-15-22 3
02-16-22 4
02-17-22 5
02-18-22 6
02-19-22 7
02-20-22 1
Page 7
ConditionalFunctions
Explanation: Conditions
We use IF to create a condition:
- IF has 3 parameters:
- The condition
- What to do in case the condition is met
- What to do in case the condition is not met
Example
'=IF(grade > 50%, “Pass”, “Fail”
Change the grade in B10 to test the function in C10
Grade: 60% Pass
Exercise
Use IF to fill out column C
Example
Here is a list of grades for both Peter and Paul. We use AVERAGEIF to calculate Paul’s average.
Student Grade
Peter 61%
Paul 72%
Paul 69%
Peter 58%
Paul 73%
Peter 59%
Page 8
ConditionalFunctions
3 4
Page 9
ConditionalFunctions
Exercise
The table below gives an overview over homeworks.
- Use COUNTIF to calculate how many times homework was handed in late
- Use SUMIF to addup the total number of exercises Jane has done.
- Use AVERAGEIF to calculate the average score of all homeworks that were handed in on time.
Page 10
LookupFunctions
INDEX
We use INDEX to look up a value from an grid. INDEX has three inputs.
INDEX(reference, row_num, column_num)
- reference: the grid
- row_num: the row value we are looking up
- column_num: the column value we are looking up (if left blank we look in the first row)
Example
d '=INDEX(B13:D15,2,1) returns the 2nd row and first column from the grid
I '=INDEX(B13:D15,3,3) returns the 3rd row and 3rd column from the grid
a b c
d e f
g h I
Exercise
Use INDEX to find the value in the first row and 2 nd column from the grid above
b
MATCH
MATCH searches for a specific value in a list, and returns it’s position
We can include a third parameter:
1: finds the closest value which is lower (only works if the list is in ascending order)
0 : only finds the exact value.
-1: finds the closet value which is larger (only works if the list is in descending order)
Example
1 '=MATCH("Bananas",A34:A38,0) returns 1 because "Bananas" is the first item in the list
3 =MATCH(42,B34:B38,1) returns 3 because 40 is the closest value which is lower
#N/A '=MATCH(39,B34:B38,0) returns an error because we are looking for an exact value, which doesn’t exist
2 '=MATCH(22,C34:C38,-1) returns 2 because 32 is the closest value which is larger
Exercise
Use MATCH to find the location of “Cucumbers”
4
Use MATCH to find the location of exactly 40 in Count1
3
Use MATCH to find the location of the first number before 44 in Count1
3
Page 11
LookupFunctions
Page 12
LookupFunctions
Example
We want to lookup the price of Bananas
- The first parameter is “Bananas”. This is the value we are looking up.
- The second parameter is A70:C75 because that’s the table where we are looking up the values.
- The third parameter is 3, because that’s the column number where we find the price.
$5.00
We want to lookup the quantity of Apples
- The first parameter is “Apples”. This is the value we are looking up
- The second parameter is A70:C75 because that’s the table where we are looking up the values.
- The third parameter is 3, because that’s the column number where we find the quantity.
5
Exercise
Use VLOOKUP to find the quantity of Pineapples
2
Use VLOOKUP to find the price of Cucumbers
Example 2
The following table shows grade boundaries. We will use this table and VLOOKUP to assign the appropriate grade.
Mark Grade
0U
24 E
30 D
36 C
42 B
48 A
Page 13
LookupFunctions
4 25 E '=VLOOKUP(B97,$A$86:$B$91,2)
5 45 B '=VLOOKUP(B98,$A$86:$B$91,2)
Exercise
Every week the price of oil changes.
The following list shows the first Monday of every week in the first column, and the price of the oil in the second column.
Use VLOOKUP to find the price of oil for the following dates:
Exercise
Use the below table to lookup the price of Bananas
Page 14