Spreadsheet - Formulas Functions and References
Learn how absolute, relative, and mixed references work, how to use conditional formulas for error highlighting, and how to create and apply built‑in and user‑defined functions and subroutines.
Summary
Read Summary
Flashcards
Save Flashcards
Quiz
Take Quiz
Quick Practice
What type of cell reference fixes the column while allowing the row to change?
1 of 7
Summary
Formulas and Cell References in Spreadsheets
Understanding Cell References
When you write a formula in a spreadsheet, you reference cells by their addresses (like A1, B2, etc.). However, cells don't always behave the same way when you copy a formula to another location. Understanding the three types of cell references is essential for working efficiently with spreadsheets.
Relative References
A relative reference is the default behavior. When you copy a formula containing a relative reference to a new location, the reference automatically adjusts based on how far you moved it. For example, if you have a formula =A1+B1 in cell C1 and copy it down to C2, the formula automatically becomes =A2+B2. The column and row both shift relative to the new position.
Relative references are useful when you want a formula to adapt as you copy it across your spreadsheet.
Absolute References
An absolute reference is locked to a specific cell and never changes, regardless of where you copy the formula. You create an absolute reference by placing a dollar sign ($) before both the column letter and row number, like $A$1.
For example, if you have a formula =A1$B$1 and copy it down to row 5, it becomes =A5$B$1. Notice that A1 became A5 (relative behavior), but $B$1 stayed locked to column B, row 1 (absolute behavior).
Absolute references are essential when you need a formula to always reference the same cell—such as when dividing all values by a single constant, or applying a tax rate stored in one cell to multiple rows.
Mixed References
Mixed references combine absolute and relative behavior by locking either the column or the row, but not both.
Absolute column, relative row (written as $A1): The column is locked, but the row changes when you copy the formula. If you copy =$A12 down to row 5, it becomes =$A52.
Relative column, absolute row (written as A$1): The row is locked, but the column changes when you copy the formula. If you copy =A$12 to the right to column D, it becomes =D$12.
Mixed references are useful in more complex spreadsheets where you want partial locking of cell references.
Conditional Formulas and Error Highlighting
What Are Conditional Formulas?
A conditional formula evaluates whether something is true or false, and then returns different values or messages based on that evaluation. Unlike arithmetic formulas, conditional formulas don't necessarily perform calculations—they make decisions.
The most common conditional formula uses the IF function:
$$\text{=IF(condition, value\if\true, value\if\false)}$$
For example:
=IF(A1>100, "High", "Low") returns "High" if A1 is greater than 100, otherwise returns "Low"
=IF(B2<0, "ERROR", B22) checks if B2 is negative and either shows "ERROR" or calculates B22
Nested Conditions
You can embed multiple IF statements inside each other to handle more complex scenarios:
$$\text{=IF(A1>100, "Very High", IF(A1>50, "Medium", "Low"))}$$
This checks if A1 is greater than 100 (returns "Very High"), and if not, checks if it's greater than 50 (returns "Medium"), and if neither is true, returns "Low".
Using Formulas to Highlight Errors
Spreadsheets can contain errors—typos, invalid data, or values that shouldn't exist. You can write conditional formulas specifically to identify and flag these errors. For instance:
=IF(D1="", "MISSING DATA", D1) highlights empty cells
=IF(OR(E1<0, E1>1000), "OUT OF RANGE", "OK") checks if a value is outside acceptable bounds
These formulas help maintain data quality by automatically catching problems rather than requiring manual review.
Functions and Subroutines
Built-In Functions
Spreadsheets come with hundreds of pre-written functions that perform common calculations and operations. These built-in functions save you time and reduce errors.
Common categories include:
Arithmetic functions: SUM, AVERAGE, MIN, MAX, COUNT
Trigonometric functions: SIN, COS, TAN, SQRT
Statistical functions: MEDIAN, STDEV, VARIANCE
Text functions: CONCATENATE, LEN, UPPER, LOWER
Date/time functions: TODAY, NOW, MONTH, YEAR
For example, =SUM(A1:A10) adds all values from A1 to A10, and =AVERAGE(B1:B5) calculates the average of cells B1 through B5.
Understanding Function Syntax
Functions follow a standard pattern:
$$\text{=FUNCTIONNAME(argument1, argument2, ...)}$$
The equals sign tells the spreadsheet this is a formula. The function name describes what it does. Arguments (also called parameters) are the inputs the function needs. Some functions require arguments, others don't.
User-Defined Functions
While built-in functions cover many needs, you sometimes need specialized calculations that don't exist as standard functions. This is where user-defined functions come in—custom functions you create yourself using Visual Basic for Applications (VBA).
Creating a User-Defined Function
To create a user-defined function, you access the Visual Basic editor and write code structured like this:
vba
Function FunctionName(parameter1, parameter2)
FunctionName = parameter1 + parameter2
End Function
Once you write and save the function, it becomes available on your worksheet just like built-in functions. You can then call it with =FunctionName(value1, value2).
Key difference from subroutines: User-defined functions return a value that appears in the cell where you write the formula. This makes them perfect for calculations.
When to Use User-Defined Functions
Create a user-defined function when you need to:
Perform a complex calculation repeatedly
Encapsulate logic that's too complex for a single built-in formula
Create a reusable calculation across multiple worksheets
Naming Variables and Functions with the Name Manager
Rather than constantly referencing cells by their addresses (like B2 or C5), you can assign meaningful names to cells and ranges. The Name Manager is the tool that stores these definitions.
For example, instead of writing =A1$B$1, you could name A1 as "Price" and B1 as "TaxRate", then write =PriceTaxRate. This makes your formulas far more readable and easier to maintain.
How to Use the Name Manager
The Name Manager typically appears as a dropdown box on the left side of the formula bar. You can:
Click on a cell or range
Type a name in the Name Manager box
Press Enter to create the named reference
Now, whenever you reference that name in a formula, it automatically points to the correct cells. If you later move the cells, the name stays with them.
Why Use Named References?
Clarity: =SalaryTaxRate is far clearer than =A2$C$1
Maintainability: If you rename a cell's purpose, the formula still makes sense
Reduced errors: You're less likely to reference the wrong cell when the name makes the intent clear
Easier collaboration: Other people reading your spreadsheet understand what each formula does
Subroutines: Writing Values Directly to the Worksheet
While user-defined functions return a value to a cell, subroutines (often called "Subs") are VBA procedures that can perform actions directly on the worksheet without returning a value through a formula.
Key Differences: Functions vs. Subroutines
| Aspect | Function | Subroutine |
|--------|----------|-----------|
| Returns a value? | Yes | No |
| Called from a cell formula? | Yes | No |
| Can modify cells? | Yes | Yes |
| How you run it | Include in formula | Button or menu |
How Subroutines Work
A subroutine can directly write values or text into specific cells. For example:
vba
Sub FillColumn()
Dim i As Integer
Dim n As Integer
n = Range("x").Count
For i = 1 To n
Range("y").Cells(i).Value = i ^ 2
End Sub
This subroutine loops through cells in column y and fills each one with the square of the corresponding value in column x. Notice it doesn't return anything—it directly modifies the worksheet.
When to Use Subroutines
Use a subroutine when you need to:
Perform multiple operations across several cells
Run code based on a button click or user action
Modify multiple worksheets or perform complex workflows
Write output that goes to multiple cells at once
<extrainfo>
Running Subroutines
Unlike functions which execute automatically when you enter their formula, subroutines must be triggered manually. You typically do this by:
Creating a button on the worksheet and assigning the subroutine to it
Running the subroutine directly from the Visual Basic editor
Triggering it from another macro or event
</extrainfo>
Flashcards
What type of cell reference fixes the column while allowing the row to change?
Absolute column reference (e.g., $A1)
What type of cell reference fixes the row while allowing the column to change?
Absolute row reference (e.g., A$1)
What are the two combinations that constitute mixed cell references?
Absolute column with relative row (e.g., $A1)
Relative column with absolute row (e.g., A$1)
What categories of arithmetic, mathematical, and analytical functions do spreadsheets typically provide?
Arithmetic functions (e.g., summation, average)
Trigonometric functions
Statistical functions
What environment and language are used to create custom functions that become directly accessible on the worksheet?
Visual Basic for Applications (VBA) in the Visual Basic editor
What tool allows cells to refer to meaningful names instead of raw cell addresses by storing variable definitions?
The Name Manager
What is the primary functional difference between a subroutine and a standard function regarding worksheet interaction?
Subroutines can write values or text directly into worksheet cells
Quiz
Spreadsheet - Formulas Functions and References Quiz Question 1: In a spreadsheet, what effect does an absolute column reference such as $A1 have when the formula is copied to another cell?
- It locks the column (A) while allowing the row number to adjust. (correct)
- It locks both the column and the row, preventing any change.
- It locks the row only, leaving the column free to change.
- It does not lock any part of the reference; both column and row can change.
Spreadsheet - Formulas Functions and References Quiz Question 2: Which of the following is an example of a built‑in arithmetic function provided by most spreadsheet programs?
- SUM (correct)
- CustomVBAFunction
- Manual cell addition using “=A1+A2+A3” without a function
- External data import routine
In a spreadsheet, what effect does an absolute column reference such as $A1 have when the formula is copied to another cell?
1 of 2
Key Concepts
Cell References
Absolute reference
Relative reference
Mixed reference
Spreadsheet Functions
Conditional formula
Built-in function
User-defined function
VBA and Management
Visual Basic for Applications
Subroutine
Name manager
Error highlighting
Definitions
Absolute reference
A spreadsheet cell reference that fixes both its column and row, denoted with a dollar sign before each (e.g., $A$1).
Relative reference
A spreadsheet cell reference that adjusts both its column and row when copied, without dollar signs (e.g., A1).
Mixed reference
A spreadsheet cell reference that fixes either the column or the row while allowing the other to change, using a dollar sign on one part (e.g., $A1 or A$1).
Conditional formula
A spreadsheet expression that evaluates logical conditions to return different results without performing arithmetic.
Error highlighting
The use of formulas or conditional formatting in spreadsheets to identify and visually mark erroneous data.
Built-in function
Predefined operations provided by spreadsheet software for tasks such as summation, averaging, trigonometry, and statistics.
User-defined function
A custom function created by the user, typically in Visual Basic for Applications, that can be called directly from worksheet cells.
Visual Basic for Applications
Microsoft’s event‑driven programming language used to automate tasks and create custom functions and subroutines in Office applications.
Name manager
A feature in spreadsheet programs that stores and manages named ranges, variables, and constants for easier reference.
Subroutine
A VBA procedure that performs actions such as writing values to worksheet cells but does not return a value to the calling cell.