0% found this document useful (0 votes)
477 views

Lab Manual Spreadsheets: Microsoft Excel

This document is an Excel lab manual that introduces basic Excel functions over 4 labs. Lab 1 covers the Excel interface, auto-complete, formatting, and basic calculations. It teaches how to navigate the Excel interface, format cells as dates or currencies, and perform simple calculations. Lab 2 introduces charts and pivot tables to visualize and analyze data. Lab 3 covers conditional functions like IF and lookup functions. Lab 4 demonstrates conditional formatting to visually flag data and sorting/filtering lists. The manual provides step-by-step exercises to practice these fundamental Excel skills.

Uploaded by

Rambabu Vurimi
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)
477 views

Lab Manual Spreadsheets: Microsoft Excel

This document is an Excel lab manual that introduces basic Excel functions over 4 labs. Lab 1 covers the Excel interface, auto-complete, formatting, and basic calculations. It teaches how to navigate the Excel interface, format cells as dates or currencies, and perform simple calculations. Lab 2 introduces charts and pivot tables to visualize and analyze data. Lab 3 covers conditional functions like IF and lookup functions. Lab 4 demonstrates conditional formatting to visually flag data and sorting/filtering lists. The manual provides step-by-step exercises to practice these fundamental Excel skills.

Uploaded by

Rambabu Vurimi
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/ 56

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 

Lab Manual
 
 

SPREADSHEETS
 
MICROSOFT EXCEL
 
 
 

Table of Contents
Lab 1: Excel Basics ......................................................................................................................................... 3 
 
The interface ............................................................................................................................................. 3 
 
Auto‐complete .......................................................................................................................................... 4 
 
Formatting ................................................................................................................................................ 6 
 
Basic calculations ...................................................................................................................................... 7 
 
Lab 2: Charts and Pivot Tables .................................................................................................................... 10 
 
Charts ...................................................................................................................................................... 10 
 
Pivot tables.............................................................................................................................................. 17 
 
Lab 3: Conditionals and Lookup Tables....................................................................................................... 25 
 
Conditional functions .............................................................................................................................. 25 
 
IF functions.............................................................................................................................................. 29 
 
Lookup functions..................................................................................................................................... 35 
 
Lab 4: Conditional Formatting and Lists ..................................................................................................... 39 
 
Conditional formatting............................................................................................................................ 39 
 
Sorting lists.............................................................................................................................................. 47 
 
Filtering lists ............................................................................................................................................ 51 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 


 
 
Lab 1: Excel Basics
 
 
Microsoft Excel is a spreadsheet application that is used for basic data organization, statistical analysis, 
graphing data as well as many other uses. In this lab, we will take a look at what makes up an Excel 
spreadsheet and the basic uses of it. 
 
 
 
 
The interface
 

 
1  3 
 
 
 
 
 
 
 

 
 
 


 
 
 
 
 
 
 

 

Peeking into Computer Science | Excel Lab Manual


 
1.  The File menu: This menu allows you to create, save, open and print spreadsheets. 
2.  Quick access toolbar: You can customize this toolbar to include all of the functions you use most, 
such as save and undo. 
3.  The ribbon:   The ribbon contains all the office menus and toolbars. The ribbon is divided into tabs, 
each of which contains groups of controls. 
4.  Columns: Label 4 is one of the columns in the spreadsheet. Each column is labeled by the letter (or 
a string of letters) at the top of it. 
5.  Rows: Label 5 is one of the rows in the spreadsheet. Each row is labeled by the number to its left. 
6.  Cells: A cell is the intersection between a row and column. A cell is where most of the excel data is 
entered. A  cell’s address  is the row  and column it is in, for instance,  the boxed  cell  (label 6) is in 
column E and row 13; hence, its address is E13. 
 
 
 
 
 


7.  The worksheet  toolbar:  An Excel file is called a workbook. It  consists of a number of spreadsheets 
(worksheets). This toolbar allows you to move  between the different sheets in a workbook. It also 
allows you to create new worksheets, delete existing sheets, and rename sheets. 
 
Exercise 1
1.  Enter the data “Sunday” into cell A1 and “Monday” into cell B1. 
2.  Type in “17/08” into cell E8. 
3.  Type in “2” into cell I8 and “4” into cell I9. 
 
 
 
Auto‐complete
Your worksheet should now look like this: 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
Notice  how  Excel  automatically  detected  that  17/08  was  a  date  and  converted  it  to  17‐Aug.  We  will 
discuss formatting data later on in this lab. 
 
Now, we  want to  select  both  cells  A1 and  B1  together.  To  do  this,  click  A1  and  without  releasing  the 
mouse  button,  move  the  mouse  over  cell  B1.  Now  there  should  be  a  rectangle  around  both  cells  as 
shown below. 
 
 
 
 
 
 
 
 
 
 
 
 
Lab 1: Excel Basics 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
To get excel to auto‐complete this row, we now position the mouse cursor at the bottom‐left corner of 
the rectangle. Make sure the cursor has changed into a + sign. Now hold down the cursor and drag it to 
the left till I1. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
This is what your spreadsheet should look like when you release the mouse button: 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 1: Excel Basics 

Exercise 2
1.  Auto‐complete cells I8 and I9 all the way to I14. 
2.  Auto‐complete cell E8 all the way to E12. 
 
 
 
Formatting
Excel  allows  you  to  format  your  data  so  that  it  shows  up  in  the  way  you  need  it  to.  Let  us  start  with 
number  formatting. Select cells I8 and I9.   If you take  a look at the Number group in the  Home tab on 
the ribbon, you will notice that the current number format is “General”: 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Selecting that drop down box shows you some of the available number formats, as shown below. 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 1: Excel Basics 

Select  currency  from  the  drop  down  menu.  Now,  you  will  notice  that  the  two  numbers  have  a  $  sign 
preceding them, and have two decimal places. Let us change the currency symbol to a Euro. Select the 
Euro symbol from the currency format menu. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Exercise 3
Modify cells I8 and I9 by removing the 2 decimal places. 
 
Exercise 4
Format cell E8 so that it looks like August 17, 2010. 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


Basic calculations
When working on a spreadsheet, you will almost definitely need to perform some calculations on the data 
you  have.  The  first  thing  you  need  to  remember  about  Excel  calculations  is  that  formulas  always start 
with  an  =  sign.  Let  us  begin  with  a  very  simple  calculation.  Type  “=3+5”  into  cell  A5  as  shown 
below. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 1: Excel Basics 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Press Enter. Excel automatically replaces the formula with the result of the equation. 
 
Now let us calculate the sum of the numbers in I8 and I9. In cell J10, type “=I8+I9”. One other option is 
to type in “=”, then select cell I8. After that, type in “+” and then select I9. 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 1: Excel Basics 

Pressing  Enter  will  give  you  the  result  of  the  calculation.  Double‐clicking  on  the  cell  with  the  formula 
allows you to edit the formula. 
 
Excel has built‐in functions that make your life easier. One of them is the SUM function. In cell J11, type 
“=sum(“. Now select both cells I8 and I9. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Pressing Enter gives you the same result as the plus operation we did in cell J10. Try changing the value 
in cell I8 and notice how the change is reflected in both formulas. 
 
Exercise 5
1.  Open Sheet 2 in your workbook. 
2.  In cells A1 and A2, type 1000 and 1500 respectively. 

Peeking into Computer Science | Excel Lab Manual


3.  Use auto‐complete to fill in cells A3 to A8. 
4.  Format the numbers so that they show the 1000 separator (1,000) and have one decimal place. 
5.  Calculate the following values for cells A1 to A8 using built‐in Excel functions: 
a)     Sum 
b)     Maximum 
c)          Minimum 
d)     Average 
e)     Median 
f)      Standard deviation 
6.  Enter the number 5000 into cell A9 and modify all the above formulas to include it. 
7.  Calculate  the  sum  of  the  Maximum  and  Minimum,  and  then  divide  this  number  by  the  standard 
deviation. 
 
 
 
 
 

Lab 1: Excel Basics 

Lab 2: Charts and Pivot Tables
 
 
 
Charts
Turning data into charts can help visualize the information at hand. To convey the appropriate message 
from your data, you need to select an appropriate type of chart for your data. 
 
Let us start out with creating a simple chart using the chart wizard. Open the file excellab2.xslx. In the 
total expenses sheet, you will see a table showing the total expenses accumulated by a company in the 
12 months of a particular year. Select the entire table. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
On the ribbon, click the Insert tab. There you will notice the Charts group, showing all the different types 
of charts that can be created out of the data. Select the 1st  option in 2D bars (the clustered bar chart). 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 2: Charts and Pivot Tables 
10 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
This is the chart Excel creates: 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
You may need to drag the corner of the chart to make it larger so that all the months are clearly visible 
on the y‐axis. The chart needs some tweaking. First, we need to decide what extra information we want 
the chart to show. We want this chart to have a meaningful title and show a title for the x‐axis. We do 
 
 

Lab 2: Charts and Pivot Tables 
11 
not  need  a  legend,  a  title  for  the  y‐axis  nor  data  labels.  Now  that  I  know  what  we  want,  the  chart 
becomes very easy to customize using Excel’s chart layouts. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Looking   at   Excel’s   built‐in   layouts,   you   will   notice   that   none   of   them   quite   satisfy   our   chart 
requirements. Here we have two options. One option is to select one of the layouts and modify it to fit 
our  needs.  For  instance,  we  could  pick  Layout  6  and  simply  delete  the  data  labels.  The  other  option 
would be to go to the Layout tab in the Chart Tools menu. This tab lets you fine tune the layout of the 
chart. 
 
Take a look at the Labels group in the Layout tab. Since we already have a chart title, we do not need to 
worry about it. Let us add the x‐axis title. Select Axis Titles, then hover over Primary Horizontal Axis Title, 

Peeking into Computer Science | Excel Lab Manual


and select Title Below Axis. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 2: Charts and Pivot Tables 
12 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
The chart now shows an x‐axis title: 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Exercise 1
Remove the legend through the Labels group in the Layout tab. If needed, adjust the chart size so that 
all the data are clearly visible. 
 
 
 
 

Lab 2: Charts and Pivot Tables 
13 
Now that the layout of the chart is what we want, let us enter the correct titles. Click the chart title and 
replace  it  with  “Total  expenses  for  2009”.  Do  the  same  for  the  axis  title  and  replace  it  with  “Expenses 
($)”. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Now we can play around with the chart colors. Again, Excel allows you to either select one of its predefined 
themes  or  to  change  the  background  and  colors,  one  at  a  time.  Select  Style  25  from  the 
Chart Styles group in the Design tab. 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 2: Charts and Pivot Tables 
14 
Your chart now looks like this: 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Let’s do a little more formatting. Select the chart area (the box that encompasses the chart title and plot 
area). Go to the Format tab and under Shape styles, select Subtle Effect ‐ Purple, Accent 4. 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Now, select the plot area (the area that includes the chart ONLY) and select Colored Outline ‐ Dark 1. 
 
 
 
 
 
Lab 2: Charts and Pivot Tables 
15 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
It is quite easy to change the chart type in Excel. To do this, select the chart area and go to the Insert 
tab.  Select the Clustered Column from the Column charts menu. 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
This changes the chart type as follows: 
 
 
 
 
 
 
 
 

Lab 2: Charts and Pivot Tables 
16 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Exercise 2
Using the same table (Total Expense sheet), create a 2D pie chart. Instead of showing absolute values, we 
would like  the chart to  show the percentages  that each segment makes  up as a data label. The month 
name should also be part of the label and the legend is not needed. The labels should be at the inside end 
of the data points. Make sure the chart has a meaningful  title. Adjust the  chart size so that all the  data 
is clearly  visible. Give the chart area a black border. 
 
 
 
 
Pivot tables

Peeking into Computer Science | Excel Lab Manual


Pivot  tables  are  used  to  easily  create  meaning  out  of  large  amounts  of  data.  Let  us  take  an  example. 
Open  the  departmental  expenses  sheet.  Select  the  entire  table  and  then  go  to  the  Insert  tab  on  the 
ribbon. Click the PivotTable button. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 2: Charts and Pivot Tables 
17 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
The dialog box that pops up allows you to modify the range of data to be used for the pivot table, and to 
choose where the pivot table needs to be placed. Leave everything as is and press the OK button. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 2: Charts and Pivot Tables 
18 
This is what you should get: 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Let  us  first  take  a  look  at  what  the  different  field  areas  are  used  for.  Their  usage  will  become  clear 

Peeking into Computer Science | Excel Lab Manual


shortly. 
 
 Values: this is used to display summary calculations in the pivot table. 
 Row  labels:  these  labels  are  used  to  display  fields  as  rows  on  the  side  of  the  pivot  table.  The 
table is broken down by the first row label; each subsequent label appears as subcategory of the 
previous label. 
 Column labels: these labels are used to display fields as columns on the top of the pivot table. 
Column labels are nested in a similar way to row labels. 
 Report filter: this is used to filter the whole report (the pivot table). 
 
 
 
The pivot table menu to the right allows you to select the fields you want to add to the table. Select all 
of the fields by clicking their respective checkboxes. 
 
 
 
 

Lab 2: Charts and Pivot Tables 
19 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
At this stage, the pivot table does not look like anything that makes sense. We need to tweak it a  little 
bit to show the information we need. Notice that all the fields have come under Row Labels, except for 
Expense, which is under Values. 

Peeking into Computer Science | Excel Lab Manual


 
Drag the Expense Type field to Report Filter. Drag the Department field to the Column Labels. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Lab 2: Charts and Pivot Tables 
20 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Notice how more meaningful the pivot table has become. It shows the total departmental expenditures 
per month, as well as each person’s expenditures in each month.  To rearrange the months so that they 
are in the correct order, select the cell you want reordered and then move the mouse along the borders 
of the cell until a 4‐headed arrow appears. You can then drag the cell to its new location. 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Now assume that we only want the information for Travel and Social expenses. Click on the drop‐down 
field next to  Expense type, and then check the Select Multiple Items checkbox. After  that,  deselect  the 
Expense types we do not need and click OK. 
 
 

Lab 2: Charts and Pivot Tables                                                                                                                                          
21 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Now, the pivot table shows the information for only the required expense types. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
You can also filter column and row labels in the same way. Excel pivot tables allow for different calculations 
of the data value. Currently, the Expenses are being summed up. Let us modify this so that the table shows 
the average of all expenses. 
 
In the  pivot table  field list (to  the  right  of the  screen),  click  on Sum  of Expenses and select  Value  Field 
settings from the menu. 
 
 

Lab 2: Charts and Pivot Tables 
22 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
The dialog box allows you to select the calculation type for the data field. Select Average and then press 
the OK button. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 2: Charts and Pivot Tables 
23 
The pivot table now shows the average of expenses instead of the sum. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Exercise 3
Modify  the  pivot  table  so  that  it  shows  the  number  of  times  expenses  incurred  for  each  month,  per 
department and per employee, for all expense types. 
 
Exercise 4
Go to the exercise4 sheet in the excellab2.xlsx workbook. The data in the table shows the population 
in Canada by age and sex group for 2009. 
a)  Calculate the totals for each column and row (hint: try dragging the formula). 

Peeking into Computer Science | Excel Lab Manual


b)  Make sure all your data shows the 1000 separator mark. 
c)  Create  a  meaningful  chart  out  of  this  table.  Make  sure  you  include  titles  and  data  labels  as 
appropriate. 
d)  Modify both the chart and plot area backgrounds to colors of your choice. 
 
Exercise 5
Go to the exercise5 sheet in excellab2.xlsx. 
 

a)  Format the dates so that they are in the dd/mm/yyyy format. 
b)  Format the expense amounts so that they show the $ sign (without decimal places). 
c)  Create  a  pivot  table  that  shows  the  total  amounts  spent  on  groceries  and  clothes,  by  date  and 
store. 
 
 
 
 
 
 

Lab 2: Charts and Pivot Tables 
24 
Lab 3: Conditionals and Lookup Tables
 
 
 
Conditional functions
One  very  useful  set  of  built‐in  functions  in  Excel  is  conditional  functions.  As  the  name  implies,  these 
perform certain operations based when a specified condition is satisfied. This is best illustrated through 
an example. Open excellab3.xslx and go to the sheet named conditions. Now, let us use Excel to give us 
a count of the number of employees in each department. 
 
For this, we use the function COUNTIF. The form of this function is COUNTIF(Range, Criteria). The range 
is the data values you would like the count to be performed on, and the criteria are the conditions that 
need to be satisfied for a cell to be included in the count. 
 
Let us count the number of employees in the IT department. Type =countif( and then select the range of 
cells we would like to count. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
Now we need to enter the criteria. 
 
 
 
 
 
 
 
 
 
 

Lab 3: Conditionals and Lookup Tables 
25 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Note  that  IT  was  placed  between  quotation  marks,  as  should  any  criteria  you  enter.  When  you  press 
Enter, the result of the formula is shown. 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 3: Conditionals and Lookup Tables 
26 
Exercise 1
a)     Calculate the number of employees in the Accounting department. 
b)  Calculate  the  number  of  employees  with  a  salary  greater  than  15000  (remember  the  quotation 
marks around the entire criteria). 
 
Now let us try using a cell address as a criterion. We would like to find the number of employees who have 
a  salary  greater  than  Reagan’s  salary.  The  only  difference  here  is  that  to  include  a  cell  address  in the 
criterion; there is a special syntax as shown below. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
In  other  words,  the  operation  symbol  remains  between  quotations  and  then  the  cell  address  is 
appended to it using an ampersand (&). 
 
 
 
 
Exercise 2
a)     Calculate the number of employees who are NOT in the IT department. (hint: the not equal sign is 
<>) 
b)     Calculate  the  number  of  employees  with  a  salary  greater  than  or  equal  to  Alexis’,  and  less  than 
Trey’s. Remember to use cell addresses. (Hint: use two countif operations.) 
 
SUMIF works  in almost  the  same  way  as COUNTIF,  except  it  returns the sum  instead of the  count.  For 
instance, let us calculate the sum of all salaries greater than 15000. 
 
 
 
 

Lab 3: Conditionals and Lookup Tables 
27 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
SUMIF also lets you define separate ranges for the criterion and the summation. For example, we might 
want to calculate the sum of all salaries of the IT department. 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 3: Conditionals and Lookup Tables 
28 
As you can see above, we first provide the formula with the range of values on which the criteria will be 
applied.  We then enter the criteria, followed by the range which is to be summed up if the criteria apply 
to the 1st  range. 
 
Exercise 3
a)  Calculate the sum of all salaries that are below the average of salaries. 
b)  Calculate the sum of salaries of the HR and Accounting departments. 
c)     Using AVERAGEIF, calculate the average of all salaries that are less than or equal to Stacey’s. 
 
 
 
IF functions
IF  functions  or  statements  allow  you  to  ask  the  question  “is  this  true  or  false?”  It  then  allows  you  to 
implement  different  actions  based  on  the  outcome.  That  is,  it  allows  you  to  compute  two  different 
outcomes  based  on  whether  a  certain  criterion  (logical  test)  is  true  or  false.  The  format  of  an  IF 
statement is as follows: 
 
=IF(logical test, value if true, value if false). 
 
In  excellab3.xslx,  open  the  if  statements  sheet.  The  grades  shown  are  for  a  pass/fail  course,  with  the 
passing grade starting at 60. Let us use IF statements to display which students have passed, and which 
have failed. 
 
First, start with the logical condition that needs to be evaluated. In this case, a student passes the course 
if her/his grade is greater than or equal to 60, say. The symbol >= means greater or equal. 

Peeking into Computer Science | Excel Lab Manual

 
Lab 3: Conditionals and Lookup Tables 
29
After we formulate the logical test (the student’s grade is >= 60), enter what we want Excel to display if 
this condition was true.  In this case, we want Excel to display “Passed”. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Finally,  enter the value if  the  condition is false. The  IF function shown below reads:  if B2  is greater or 
equal to 60, then display Passed; otherwise, display Failed. 

Peeking into Computer Science | Excel Lab Manual

 
Lab 3: Conditionals and Lookup Tables 
30
Now, drag the cell with the formula into the rest of the column. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Exercise 4
The instructor for this course would like to reward the students who got a grade strictly above 85. Use if 
statements to display “Reward” or “No Reward” beside each student. 
 
Now what happens if this course was not a pass/fail course, rather one with a letter grading scheme? 
This requires the use of nested IF statements. Nested if statements allow you to embed IF statements in 

Peeking into Computer Science | Excel Lab Manual


other IF statements, capturing more complex scenarios. Assume that following is our grading scheme: 
 
>90  A 
>75  B 
>60  C 
otherwise  F 
 
Nested IF statements are done by replacing the value if false or the value if true in the function with a 
new IF statement. 

 
Lab 3: Conditionals and Lookup Tables 
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Notice that the logical condition of the IF function is similar to what we had done before: we require the 
grade cell to be greater than a certain value. Specifically, if B2>90, the Excel displays the letter mark A. If 
this condition is false, or B2 is less than or equal to 90, we need another IF condition in order to determine 
the  letter  grade  since  values  that  are  less  than  or  equal  to  90  can  result  in  different  letter marks. For 
example, 77 is a B, 65 is a C, and 20 is F. All these values are less than or equal to 90. 
 
Let us complete the entire function: 

Peeking into Computer Science | Excel Lab Manual

 
Lab 3: Conditionals and Lookup Tables 
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Notice that with each new IF statement, we opened up new parenthesis and that at the end we had to 
close all of them.  Drag the IF statement into the rest of the column. 

Peeking into Computer Science | Excel Lab Manual

 
Lab 3: Conditionals and Lookup Tables 
33
The following flowchart depicts how this IF function works. 
 
 
 
 
 
 
 
 
True  Is grade 
> 90? 
 
 
 

Print “A”  False 

 
 
True  Is grade 
> 75? 
 
 
Print “B”  False 

 
 
True  Is grade  False 
> 60? 

 
 
Print “C”  Print “F” 
 
 
 
If B2>90, the A is displayed. If this logical condition is false (B2 is less than or equal to 90), a new if function 
takes  effect:  IF  (B2>75,”B”,IF(B2>60,”C”,”F”)).  In  this  function,  the  logical  test  is  B2>75,  the value if 
true  is  B,  and  the  value  if  false  is  another  if  function:  IF  (B2>60,”C”,”F”).  Hence,  if  B2>75  is  true,  B  is 
displayed. If not, we need to check the mark if it is a C or an F. If B2>75 is false the last if function takes 
effect: IF (B2>60,”C”,”F”). If B2>60, display 60; otherwise, display F. 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
Exercise 5
Open  the  if  exercise  sheet.  The  sheet  shows  the  names  of  salespeople  along  with  the  revenues  they 
have  brought  to  the  company.  Using  if  functions,  calculate  their  bonuses  based  on  the  following 
scheme: 
 
>=$15000  10% bonus 
>=$10000  8% bonus
>=$7000  5% bonus
otherwise  No bonus 

 
Lab 3: Conditionals and Lookup Tables 
34
Lookup functions
You may have noticed that some of these if statements can get quite long. An easier way to match up 
the grades to their corresponding letter grade is to use the LOOKUP function. 
 
The  first  thing  you  need  to  do  is  to  create  a  lookup  table  that  displays  which  numerical  grades 
correspond to which letter grades. This is the grade distribution: 
 
A            >=90 
B            >=80 
C            >=65 
D            >=50 
F            otherwise 
 
Open the lookup sheet. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
Notice that the lookup table is in ascending order (by the first column). It must be in ascending order for 
LOOKUP  to  work.  The  way  this  table  is  interpreted  is  that  we  are  providing  Excel  with  the  minimum 
numerical grade for each letter grade. For instance, the F grade is between 0 and 50 (since a D starts at 
50), not including 50. The A grade is anything greater than or equal to 90. If we had not set the minimum 
numerical grade for F as 0, any value below 50 would return an error. 

Now let us put this table into action, using a LOOKUP function. 

 
Lab 3: Conditionals and Lookup Tables 
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
The  first  parameter  we  give  the  lookup  function  is  the  value  to  be  looked  up,  which  in  this  case,  the 
numerical grade. The second input is the lookup table. Now drag the function to the rest of the column. 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
As you can see, we received plenty of error values. Double‐clicking one of those values will show you the 
problem. When we dragged the formula, the address of the lookup table was incremented. Therefore, 
 

Lab 3: Conditionals and Lookup Tables 
36 

 
we need to fix the lookup table address in the formula. The way this is done is by adding $ as prefixes in 
cell  addresses.  The  $  sign  before  a  column  name  or  a  row  number  signifies  an  “absolute”  or  fixed 
address.  When  the  formula  is  copied,  Excel  does  not  change  absolute  addresses.  To  the  contrary,  the 
reference D2 is called a “relative”  address. In essence,  it is saying lookup the value  immediately to the 
left of cell E2 (where the lookup function is created) and go from there. So, when the formula is copied 
from E2 to E3, D2 will be updated to D3. Lookup tables should be always referenced in an absolute way. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
A  shortcut  to  do  this  is  by  clicking  on  F4  right  after  selecting  the  lookup  table.  Now  try  dragging  the 
formula again. 

Peeking into Computer Science | Excel Lab Manual

 
Lab 3: Conditionals and Lookup Tables 
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Now it all looks good, and as you can see above, the address of the lookup table was fixed. 
 
Remember: 
‐  The lookup table must be in ascending order. 
‐  If   lookup   cannot   find   the   exact   match   to   the   value   you   provided,   it   will   return   the   result 
corresponding to the largest value that is less than or equal to the value you provided. 
‐  If the value you are looking for is smaller than the smallest value in the table, an error value will be 
returned. 
 
 
 

Peeking into Computer Science | Excel Lab Manual


Exercise 6
The following table provides the color frequencies in the visible spectrum 
(http://en.wikipedia.org/wiki/Visible_spectrum). 
 
Color  Frequency (THz) 
Violet  669‐789 
Blue  631‐668 
Cyan  607‐630 
Green  527‐606 
Yellow  509‐526 
Orange  485‐508 
Red  400‐484 
 
In the lookup exercise sheet, fill in the colors corresponding to the given frequencies using the lookup 
function. 

 
Lab 3: Conditionals and Lookup Tables 
38
Lab 4: Conditional Formatting and Lists
 
 
 
Conditional formatting
Conditional formatting allows you to make data trends stand out visually. 
 
Open  the  file  excellab4.xslx  and  navigate  to  the  condForm  sheet.  Let  us  say  we  would  like  to  quickly 
view who has OT (Over Time hours) more than 10 hours. 
 
First, start by selecting your data range: 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
In  the  Home  tab,  click  on  Conditional  Formatting  in  the  Styles  group.  Move  the  mouse  pointer  over 
Highlight Cells Rules, and then click Greater Than. 

 
Lab 4: Conditional Formatting and Lists 
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
In the dialog box that pops up, Enter 10. Notice that you can modify the way that the cells are formatted 
by  choosing  the  fill  and  text  colors  from  the  drop  down  list  labeled  with.  For  this  exercise,  leave  the 
formatting as light red for the fill and dark red for the text. Click the OK button when you are done. 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
Now, OT hours that are greater than 10 have been highlighted. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
40 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Exercise 1
Highlight the Hours that are in the bottom 20%. Format them so that they have a Yellow Fill with Dark 
Yellow Text. (Hint: use Top/Bottom Rules). 
 
 

Peeking into Computer Science | Excel Lab Manual


 
Other  conditional  formatting  features  allow  you  to  get  a  quick  overview  of  the  values  of  all  cells  in  a 
range.  One of  them  is  data  bars.  Data  bars assign  the  longest  bar to  the  largest  value  in  a  list  and  the 
shortest bar to the smallest value. The values in between are then given bars according to their respective 
values. Let us apply this to the Total column. 
 
Select the range of cells under the Total heading.   Click on the Conditional Formatting button and navigate 
to the Data Bars menu. Select the Purple Data Bar button. 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
41 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
The data bars now provide you with a quick relative view of the total amounts employees earn. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Using color scales also gives you a similar result as data bars. Both features allow you to get a quick view 
of how your data values compare to one another. The 2‐color scales assign one color to the maximum 
 
 

Lab 4: Conditional Formatting and Lists 
42 

 
value  and  another  to  the  minimum.  The  values  in  between  get  assigned  “in‐between”  colors.  In 
addition, the 3‐color scales assign a color to a selected midpoint. The colors and values assigned to them 
can be modified by selecting Manage Rules under the Conditional Formatting header. 
 
You can also delete rules by selecting the cells where you would like to clear the rules, then navigating 
to the Clear Rules menu under Conditional Formatting. Click on Clear Rules from Selected Cells. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Exercise 2
After  you  have  cleared  the  data  bars  rule  from  the  Total  column,  apply  the  Green‐Yellow‐Red  color 
scale. 

Peeking into Computer Science | Excel Lab Manual


 
Exercise 3
Edit this rule so that the maximum value is shown in a pretty sky blue color. 
 
The final aspect of conditional formatting we will  cover  is  icon sets.   When using icon sets, each cell  is 
provided with an icon depending on its value. There are no gradients in icon sets. 
 
Let us format the Rate column using icon sets. Select the cells in the Rate column and apply the 3 traffic 
lights (rimmed) formatting to them, as shown below. 
 
 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
43 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
As you can see below, Excel assigns the icons based on its own calculations. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
If you want to change the way that the icons are assigned, you need to edit the rule (Manage Rules). As 
you can see  below,  Excel  is  currently  assigning  the  Green icon  to values  >= the 67  percent.  What this 
 
 

Lab 4: Conditional Formatting and Lists 
44 

 
means is that Green icons will be assigned to values >= 67 percent between the lowest value (8.5) and 
the highest (15). In this case, the minimum value associated with 67 percent is 0.67*(15‐8.5)+8.5. This is 
12.9. In other words, Excel calculates these percentages by assigning 100% to the highest value in the 
range and 0% to the lowest. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Let us change the type of values to Percentile instead of Percent. 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
Notice the changes in the distribution of icons. 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
45 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Percentiles do not calculate the percentages within ranges of values. Percentiles are based on the order 
of a value among the other values.  Values <= the 33 percentile means that red icons will be assigned to 
the bottom 4 values. If you are interested in the Math, this is because 0.33*13 (the number of values) = 
4.29. 
 
What  you  need  to  understand  about  this  is  that  percentages  are  calculated  relative  to  the  lowest  and 
highest  values  when  percentiles  are  calculated  based  on  the  position  of  a  value  in  the  ordered  list  of 

Peeking into Computer Science | Excel Lab Manual


values. 
 
 
 
 
Exercise 4
Format the OT Rate column using the 3 flags icon style. The cells should show a RED flag if its value is 
>=20, a YELLOW flag if its value is <20 and >=15, and GREEN otherwise. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
46 

 
Sorting lists
Sorting a list or sorting an entire table are both functions that will most likely come up whenever you are 
doing data analysis. You can easily sort data in alphabetic, numeric, or even chronological order. 
 
Let us try sorting our table by the ascending alphabetic order of the names of the employees.  Select the 
range of names in the table.  Then in the Home tab, under the Editing group, select Sort A to Z. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
A warning message pops up: 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
What this message is telling us is that with the current selection, only the names column will be sorted. 
The data in the rest of the table will not be sorted. This is why we need to select the “Expand the selection” 
radio  button. This will allow the entire table  to be sorted according the alphabetic order of 
the names. Press the Sort button. The entire table has now been sorted. 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
47 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Exercise 5
Sort the table through the Hours column, from largest to smallest. 
 
Excel also lets us perform more complicated sorting. Let us try to sort the table by the cell icons of the 
Rate column. 

Peeking into Computer Science | Excel Lab Manual


 
Select the entire table.  Under Sort and Filter, select Custom Sort. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
48 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
The custom sort dialog box pops up. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
This dialog box shows the column headers in our table, how we want to sort them, and what order we 
want them in. 
 
Select Rate as the Sort by column, and then select for it to be sorted on Cell Icon.  The order menu now 
shows the three  icons  used  in  the  Rate  column.  Let  us  ask  for the  green icon  to  be  placed  on top, as 
shown below. 
 
 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
49 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Now we can add another level of sorting so that the red icon is  at the bottom. Click on the Add Level 
button in the dialog box. Select Rate and Cell Icon again. This time, make sure the red icon is ordered on 
the bottom, and then click the OK button. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
50 

 
This is what your table should look like: 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Exercise 6
Use custom sort to sort the table in the descending order of the OT Rate and then in ascending order of 
the names of the employees. 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
Filtering lists
Filtering in Excel allows you to show only the rows of data you are concerned with, and hide all other 
data temporarily. 
 
Open the filters sheet in excellab4.xslx. 
 
One obvious use for filters here is to view the sales information of only a few regions of interest. Let us 
see how this can be done. 
 
Start by selecting the Region column. Under the Home tab and in the Editing Group, select the Sort and 
Filter button. Select Filter from the menu. 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
51 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Notice  that  there  is  now  an  arrow  next  to  the  Region  header.  This  arrow  means  that  a  filter  can  be 
applied to this column, but no filters are currently being used. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
52 

 
Click the arrow next to the Region header. Let us only show the data for sales in the East region. One 
way to do this is to deselect NW and SW as shown below. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Now, only the rows showing information from either the NE or SE are shown. Notice the button next to 
the region header has changed to a filter icon indicating that a filter has been applied. 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
53 

 
There is another way  by which the same result can be  achieved. First let us remove the applied filter. 
Click on the button next to Region and select “Select All”. Click the OK button. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Now that we can see our original data, let us add a new filter. Select the arrow next to Region and move 
the mouse cursor over Text Filters. Choose Ends With. 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
54 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
In the dialog box that pops up, enter E as shown below. This will only show the rows in which the Region 
ends with an E. Click on the OK button. 
 
 
 
 
 
 
 

Peeking into Computer Science | Excel Lab Manual


 
 
 
 
 
 
 
Now  let  us  remove  the  filter  by  clicking  on  the  button  next  to  Region  and  selecting  Clear  Filter  from 
“Region” from the menu. 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lab 4: Conditional Formatting and Lists 
55 

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Exercise 7
Create  a  new  filter  that  only  shows  the  data  for  salespeople  who  have  joined  after  May  2004, 
and 
before or during May 2008. Filter this further so that it only shows the ones who have sales less 

Peeking into Computer Science | Excel Lab Manual


than 
$6000 or greater than $12000. 
 
Exercise 8
Remove the previous filters from the table.   Show only the rows from the months April, May, 
and June of all the years (2nd  quarter).  From those rows, only show the ones with Sales above 
the average. 
 

56
 

You might also like