Adv. Excel and Visualization
Practical 6 – Mastering Formulas and Cell References
1. Objective
The primary objective
of this practical is to provide students with a deep understanding of how
formulas work in Microsoft Excel, beyond just basic function usage. Students
will learn to:
·
Effectively use basic
arithmetic operators in formulas.
·
Differentiate and apply
relative, absolute, and mixed cell references to build robust and efficient spreadsheets.
·
Identify and
troubleshoot common formula error types (e.g., #DIV/0!, #####, #VALUE!).
·
Construct dynamic
formulas that adapt correctly when copied.
2. Introduction
Formulas are the
analytical engine of Excel, transforming raw data into meaningful information.
Mastering formulas isn’t just about knowing specific
functions; it’s about understanding how Excel interprets cell addresses
(references) when formulas are moved or copied. This practical will demystify
cell referencing, a critical concept for creating scalable and error-free spreadsheets, and introduce you to common formula errors to
help you diagnose and fix issues efficiently.
3. Pre-requisites
·
Successful completion
of Practical 3.
·
Basic understanding of
Microsoft Excel interface and data entry.
·
Familiarity with basic SUM and IF functions.
4. Software Required
·
Microsoft Excel
5. Procedure: Practical Steps with Examples
Ensure you have your
completed marksheet from Practical 3 open. We will
use this table to demonstrate and practice formula concepts.
Step 5.1: Opening the Marksheet and Reviewing Basic Formula Setup
1.
Open
the Marksheet:
Open the Excel workbook containing your Marksheet from Practical 3. Ensure all Total Marks, Percentage,
Grade, and Result columns are calculated correctly.
2.
Review
SUM Formula:
Click on cell G4.
Observe the formula =SUM(B4:F4).
3.
Review
Percentage Formula:
Click on cell H4.
Observe the formula =G4/500.
Step
5.2: Basic Arithmetic Operators
Excel uses standard
mathematical operators:
·
+
·
-
·
*
·
/
·
^
Let’s calculate the
difference between Subject 1 and Subject 2 marks for each student.
1.
Add
a New Column: In cell K3, type Sub1-Sub2 Diff.
2.
Enter
Formula: In cell K4, type =B4-C4 and press Enter.
o Explanation: This formula directly subtracts the value in C4 from B4.
3.
Copy
Down: Use the fill
handle to drag the formula from K4 down to K8.
o Observation: Notice how B4-C4 automatically changed to B5-C5, B6-C6, etc., when copied down. This is an example of Relative Reference.
Step
5.3: Understanding Relative References
When you copy a formula
to another cell, Excel by default changes the cell references relative to the
new position.
1.
Example
from Previous Steps:
o In G4, the formula is =SUM(B4:F4).
o When copied to G5, it becomes =SUM(B5:F5). Excel moved the row number down by one because you copied
the formula down by one row.
2.
Key
Takeaway: Relative references are
useful when you want to perform the same calculation for different rows or
columns of data.
Step
5.4: Absolute References ($)
An absolute reference
always refers to the same cell, no matter where the formula is copied. You
achieve this by placing a dollar sign $ before the column letter and/or row number (e.g., $A$1).
Let’s calculate a
"Bonus Amount" for each student based on their Total
Marks and a fixed Bonus
Rate.
1.
Add
Bonus Rate: In an empty cell
outside your main data (e.g., L1), type Bonus Rate. In cell M1, enter 5% (or 0.05). This will be our fixed rate.
2.
Add
a New Column: In cell L3, type Bonus Amount.
3.
Enter
Formula with Absolute Reference: In
cell L4,
type =G4*$M$1
and press Enter.
o Explanation:
§ G4 is a relative
reference to Alice’s Total Marks. It will change to G5, G6, etc., when copied down.
§ $M$1 is an absolute
reference to the Bonus Rate. The dollar signs lock both the column (M) and the row (1), so it will always refer to cell M1, even when the formula is copied.
4.
Copy
Down: Use the fill
handle to drag the formula from L4 down to L8.
o Observation: All bonus amounts are correctly calculated using the Total
Marks of each student and the same Bonus
Rate from M1. If you examine L5, the formula is =G5*$M$1, demonstrating how G4 changed but $M$1 remained constant.
5.
Test: Change the Bonus Rate in M1 to 10%. Observe how all the Bonus Amount calculations automatically update.
Step
5.5: Mixed References
A mixed reference has
either the column or the row fixed, but not both (e.g., $A1 locks the column, A$1 locks the row). This is useful for calculations across
rows and columns where one dimension needs to stay constant.
Let’s calculate each
student’s mark for each subject as a percentage of their own total marks.
1.
Add
New Column Headers: Starting from M3, type Sub1 % of Total, Sub2 % of Total, …, Sub5 % of Total. For simplicity, let’s just do one example here, Sub1
% of Total.
2.
Focus
on one Subject’s Percentage: In
cell M4,
type =B4/$G4
and press Enter.
o Explanation:
§ B4 is relative
(Subject 1 marks for Alice). When copied across, it should become C4, D4, etc. When copied down, B5, B6.
§ $G4 is a mixed
reference. The $ before G means the column G is fixed (it will always refer to the Total
Marks column). The 4 is relative,
so it will change to 5, 6, etc., when copied down for other students.
3.
Format
as Percentage: Format cell M4 as a percentage with one decimal place (Home tab >
Number group > % button).
4.
Copy
Across: Drag the fill handle from M4 to Q4 (if you added headers for all 5 subjects).
o Observation: M4 (=B4/$G4) becomes N4 (=C4/$G4), O4 (=D4/$G4), etc. The $G part correctly stayed fixed to the Total Marks column,
while the Subject column (B, C, D, etc.) changed.
5.
Copy
Down: Select M4:Q4 (or just M4 if you’re doing one column) and drag the fill handle down
to the last student.
o Observation: For Alice, for example, her Subject
1 % of Total is B4/$G4. For Bob, it becomes B5/$G5. The row number for $G correctly changed because the row part 4 was relative.
Step
5.6: Common Formula Error Types
Understanding common
error messages helps in debugging.
1.
#DIV/0!:
o Go to a blank cell (e.g., M10). Type =10/0 and press Enter.
o Explanation: You cannot divide a number by zero. If a cell referenced
in your division formula becomes zero, you’ll get this error.
2.
#####:
o In cell M11, type a very long date or number (e.g., 12/25/2025
10:30:00 AM).
o Reduce the width of column M until ##### appears.
o Explanation: The cell contains a value, but the column is not wide
enough to display it. Excel often displays dates and times as ##### when this happens.
3.
#NAME?:
o In cell M12, type =SM(B4:F4) (instead of SUM).
o Explanation: Excel doesn’t recognize the function name SM. This error occurs when there’s a typo in a function name
or a defined name isn’t recognized.
4.
#VALUE!:
o In cell M13, type =B4+"text" (trying to add a number to text).
o Explanation: This indicates a problem with the type of value used in a
formula. For instance, trying to perform a mathematical operation on text.
5.
#REF!:
o In cell M14, type =G4. Then, delete column G (right-click column G header > Delete).
o Explanation: The formula refers to a cell that has been deleted or is
invalid. Excel tries to fix references, but if the referenced cell is gone, #REF! appears. (Undo the deletion to
restore your marksheet!)
Step
5.7: Using IFERROR for Robust
Formulas
To make your formulas
more robust and user-friendly, you can use the IFERROR function to display a custom message or a blank cell
instead of an error message.
1.
Modify
the Division by Zero Example: In
cell M10,
change the formula to =IFERROR(10/0,
"Cannot divide by zero").
o Observation: Instead of #DIV/0!, the cell now displays "Cannot divide by zero".
2.
Apply
to Marks: If you anticipate a scenario
where Total Marks might be zero, causing #DIV/0! in your Percentage column (H4), you could modify it:
o In H4, change =G4/500 to =IFERROR(G4/500,0) or =IFERROR(G4/500,"N/A"). This would display 0 or "N/A" if G4 were 0, instead of an error.
6. Exercises / Tasks
Apply the concepts
learned to complete the following tasks using your marksheet:
1.
Calculate
"Adjusted Score": Add
a new column called Adjusted Score. Assume each student gets an additional 10 marks if their Total
Marks are below 300, otherwise no
adjustment. This will require IF and addition.
2.
Subject
Weightage Calculation:
o In cells N1 to R1, enter Sub1 Weightage, Sub2 Weightage, …, Sub5 Weightage.
o In N2 to R2, enter percentage values for each subject’s weightage
(e.g., 20%, 15%, 25%, 20%, 20%). Ensure the total weightage adds up to 100%.
o Create a new column Weighted Total. In this column, calculate the weighted total for each
student: (Subject1 * Sub1 Weightage) + (Subject2 * Sub2
Weightage) + .... Use absolute
references for the weightage cells so they don’t change when
copied down.
3.
Find
Percentage of Class Average (with Absolute Reference):
o Calculate the overall average percentage of all students
in an empty cell (e.g., M15) using the AVERAGE function on column H.
o Create a new column Vs. Class Avg. In this column, calculate how much higher or lower each
student’s Percentage
is compared to the overall average percentage. For example, Alice's Percentage -
Overall Avg Percentage. Use an absolute reference for the overall
average percentage cell.
4.
Error
Prevention: Identify a formula in
your marksheet (e.g., the Percentage calculation if a student had 0 total marks) where an error
might occur. Modify that formula using IFERROR to display a user-friendly message or a specific value
instead of a standard Excel error.
7. Assessment / Deliverables
·
Submit the completed
Excel workbook (.xlsx file) with the Marksheet sheet, including all new columns and formulas from the
procedure and exercises.
·
Ensure all cell
references (relative, absolute, mixed) are correctly applied and explained if
asked.
·
Demonstrate an
understanding of formula error types and how to use IFERROR.
·
Be prepared to explain
the rationale behind your choice of cell referencing for each formula.