CDM Notes
CDM Notes
CDM Notes
Introduction
Let's say you have a worksheet with thousands of rows of data. It would be
extremely difficult to see patterns and trends just from examining the raw
information. Similar to charts and sparklines, conditional formatting provides
another way to visualize data and make worksheets easier to understand.
Data Bars are horizontal bars added to each cell, much like a bar
graph.
Color Scales change the color of each cell based on its value. Each
color scale uses a two- or three-color gradient. For example, in
the Green-Yellow-Red color scale, the highest values are green,
the average values are yellow, and the lowest values are red.
Icon Sets add a specific icon to each cell based on its value.
To use preset conditional formatting:
1. Select the desired cells for the conditional formatting rule.
3. Hover the mouse over the desired preset, then choose a preset
style from the menu that appears.
4. The conditional formatting will be applied to the selected cells.
Removing conditional formatting
We're going to use VLOOKUP to find the price of the Photo frame. You can
probably already see that the price is $9.99, but that's because this is a simple
example. Once you learn how to use VLOOKUP, you'll be able to use it with larger,
more complex spreadsheets, and that's when it will become truly useful.
We'll add our formula to cell F2, but you can add it to any blank cell. As with any
formula, you'll start with an equals sign (=). Then type the formula name. Our
arguments will need to be in parentheses, so type an open parenthesis. So far, it
should look like this:
=VLOOKUP(
Adding the arguments
Now, we'll add our arguments. The arguments will tell VLOOKUP what to search for
and where to search.
The first argument is the name of the item you're searching for, which in this case
is Photo frame. Because the argument is text, we'll need to put it in double quotes:
=VLOOKUP("Photo frame"
The second argument is the cell range that contains the data. In this example, our
data is in A2:B16. As with any function, you'll need to use a comma to separate
each argument:
It's important to know that VLOOKUP will always search the first
column in this range. In this example, it will search column A for
"Photo frame". The value that it returns (in this case, the price) will
always need to be to the right of that column.
The third argument is the column index number. It's simpler than it sounds: The
first column in the range is 1, the second column is 2, etc. In this case, we are trying
to find the price of the item, and the prices are contained in the second column.
This means our third argument will be 2:
The fourth argument tells VLOOKUP whether to look for approximate matches,
and it can be either TRUE or FALSE. If it is TRUE, it will look for approximate
matches. Generally, this is only useful if the first column has numerical values that
have been sorted. Because we're only looking for exact matches, the fourth
argument should be FALSE. This is our last argument, so go ahead and close the
parentheses:
How it works
Let's take a look at how this formula works. It first searches vertically down the first
column (VLOOKUP is short for vertical lookup). When it finds "Photo frame",
it moves to the second column to find the price.
As we mentioned earlier, the price needs to be to the right of the item name.
VLOOKUP cannot look to the left of the column that it's searching.
If we want to find the price of a different item, we can just change the first argument:
or:
It would be very tedious to edit your VLOOKUP formula whenever you want to find
the price of a different item. In the next example, we'll show how to avoid this by
using a cell reference.
Another example
Are you ready for a slightly more advanced example? We're going to make a couple
of changes to the spreadsheet to make it more realistic.
In the previous example, we typed the item name directly into the VLOOKUP
formula. But in the real world, you'll usually use a cell reference instead. In this
example, we'll type the item name in cell E2, and our VLOOKUP formula can then
use a cell reference to find information about that product. Then, we can simply type
a new item name into E2 to find any product we want.
We've also added a third column that has the category for each item. This will give
us the option of finding the price or category. Here's what the spreadsheet looks like
so far:
Our formula will be similar to the previous example, but we'll need to change the
first three arguments. Let's start by changing the first argument to a cell reference
(make sure to remove the quotation marks):
To find the category, we'll need to change the second and third arguments. First,
we'll change the range to A2:C16 so it includes the third column. Next, we'll change
the column index number to 3 because our categories are in the third column:
When you press Enter, you'll see that the Gift basket is in the Gifts category.
If we want to find the category of a different item, we can simply change the item
name in cell E2:
Part 1 of 5: VLOOKUP
This lesson is part 1 of 5 in a series. The other lessons in this unit will
build on the same example and add various types of functionality. Before
moving on, you'll want to make sure you are comfortable creating
formulas. If you'd like more practice, you can work through some of the
previous Excel Formulas lessons.
Our spreadsheet
Once you've downloaded our spreadsheet, open the file in Excel or another
spreadsheet application. It looks like we have an order invoice. There's information
about the order, along with some formulas to calculate the tax, order subtotal, and
total order cost.
Download Link: https://media.gcflearnfree.org/ctassets/topics/248/invoice_freeship_practice.xlsx
How can we solve this problem?
If the subtotal for an order is at least $100, the shipping should be free. If not, it
should cost $5.99. We could use the IF function to solve this problem. As you may
remember from our lesson on Using the IF Function, we can use it to test a
condition and then write something in a cell depending on the result. In this
example, the IF function can tell us whether the subtotal is at least $100 and then
set the shipping cost depending on the result.
Here's our function: =IF(D6>=100,0,$G$3). We'll enter this function into cell D7.
If you entered the function correctly, the shipping cost should change
from $5.99 to $0.00. That's because the Order Subtotal is more than $100.
If you want to test the function, change the value in cell C2 from 2 to 1. Because the
Order Subtotal is now less than $100, the Shipping cost should change from $0.00
to $5.99.
OK—our function is working really well! We're ready to send this back!
Part 2 of 5: VLOOKUP
How it works
Before we start using VLOOKUP, it will be helpful to know what it does. In our
example, it will search for the Product ID number on the Products worksheet. It
first searches vertically down the first column (VLOOKUP is short for "vertical
lookup"). When it finds the desired product ID, it moves to the right to find the
product name and product price.
Before we write our function, we'll need to take a moment to think carefully about
each argument and collect some information from our spreadsheet. The arguments
will tell VLOOKUP what to search for and where to look. We'll need to use four
arguments:
It's important to know that VLOOKUP will always search the leftmost
column in the cell range. Since our cell range is A2:C13, it will
search column A.
=VLOOKUP(
Next, we'll add each of the four arguments, separate them with commas, then close
the parentheses:
If you entered the function correctly, the product name should appear: Measuring
cups. If you want to test your function, change the Product ID number in cell A2
from MEA7879 to CHE7888. The product name should change from Measuring
cups to Cheesecloth.
We've got our formulas working, so we can just select cells B2 and C2 and
then drag the fill handle down to copy the formulas to the other rows in the
invoice. Now, each row is using VLOOKUP to find the Product Name and Product
Price.
OK—our functions look good. Let's send this back!
Bonus Section
Let's say a veterinarian's office is creating a spreadsheet to look up patient
information.
Here's the patient directory. This is where information will be pulled from:
Here's the patient lookup sheet. This is where the function will be inserted.
Part 3 of 5: VLOOKUP
As you can see, the VLOOKUP function isn't searching the full list of products;
it's only searching down to row 13. So it has no trouble finding the Ramekin, but it
won't be able to find the Zester, Grater, or Wire whisk.
To fix this, we'll need to change the second argument in VLOOKUP so it searches
the entire product list. There are two ways to do this:
We'll edit the function to include all of the cells in the Products table. And just in
case more products are added later, we'll increase the number of rows in the cell
range to 100. This means we're including a lot of empty rows, but that's OK—the
VLOOKUP function will still work the same way. So here's our new function:
And that's it! Now our spreadsheet's working correctly, and it'll be harder to break
these functions in the future.
Use a table
Above, we fixed our VLOOKUP function by extending the cell range to row 100.
However, if we continue adding more products, we will eventually break the
VLOOKUP function again, so this is not a perfect solution. If you're using Microsoft
Excel, a much better solution is to use a table. This will ensure that any new data
will be included automatically.
Tables work with all recent versions of Excel, but they are not currently
available in Google Sheets.
First, we'll select our product information and then convert it to a table. Note that this
will work a bit differently depending on which version of Excel you're using:
Next, we'll name the table. In this example, we'll give it the name: ProductsList.
Note that table names cannot contain spaces.
Now let's go back to our VLOOKUP function. Rather than telling VLOOKUP to
search in a specific range on the Products worksheet (Products!$A$2:$C$100), we
can simply type the name of the table (ProductsList).
If anyone ever adds information to the table, the VLOOKUP function will include it
automatically—no need to worry about updating the cell range later on. Again, you'll
need to update all of the VLOOKUP functions in the spreadsheet to refer to the table
rather than the cell range.
Part 4 of 5: VLOOKUP
=VLOOKUP(
Next, we'll add our arguments. The first argument tells VLOOKUP what to search
for. In our example, it will search for the Shipping Option, which we will be typing
in cell E6 of our Invoice.
=VLOOKUP(E6
The second argument tells VLOOKUP where to look for the value in our first
argument. In our example, that's in the Shipping worksheet, in cell range A2:B4.
We'll include some extra rows in the cell range in case more shipping options are
added later.
=VLOOKUP(E6, Shipping!A2:B10
Finally, we'll add our third and fourth arguments. In this example, the Shipping Cost
is in column B (the second column), so our third argument is 2. And because we're
only looking for exact matches, the fourth argument is FALSE.
Type the formula into cell E7 of the Invoice and press Enter to see the result.
If you typed the formula correctly, the correct shipping price should appear: $9.99. If
you want to make sure your formula is working correctly, change the Shipping
Option in cell E6 from 3-Day to 2-Day. The Shipping Cost should change from $9.99
to $13.99.
Just like before, our new formula will look at the Order Subtotal in cell E5 to see if
the value is greater than or equal to $100, so our first argument will be E5>=100.
=IF(E5>=100
The second argument looks to see if the statement in the first argument is true. If it's
true, they'll receive a credit for the cost of standard shipping (5.99). Since the credit
will be subtracted from the total order cost, we'll make it a negative number: -5.99.
=IF(E5>=100,-5.99
The third argument looks to see if the statement in the first argument is false. If it's
false, they won't receive the $5.99 shipping credit. This means our third argument
will be 0 (zero). We'll also add a close parenthesis after the last argument. Here's
our new IF function:
=IF(E5>=100, -5.99, 0)
When you press Enter, the correct discount should appear in cell E8.
If we look at the formula that calculates the Total Order Cost in cell E9, we can
calculate the total value of Order Subtotal, Shipping Cost, and Discount. We'll
simply add all three values; since the Discount is a negative number, that value will
be subtracted from the Total Order Cost.
OK—our formulas look good. Let's send this back!
Part 5 of 5: VLOOKUP, DATA
VALIDATION
Data validation
Data validation allows you to control exactly what a user can enter into a cell. In
our example, we can use data validation to ensure that the user chooses one of the
three possible shipping options. To make things even easier, we can insert a drop-
down list of the possible options.
This kind of data validation allows you to build a powerful, fool-proof spreadsheet.
Since users won't have to type in data manually, the spreadsheet will be faster to
use, and there's a much lower chance that someone can introduce an error.
Depending on what spreadsheet program you're using, the process of adding data
validation will vary. We'll show you how to add data validation in Microsoft
Excel and Google Sheets.
3. A dialog box will appear. Type a name for the cell range in
the Name: field and then click OK. In our example, we'll name
it ShipRange.
4. Click OK. The cell range will be named.
If you ever add more data to your spreadsheet, you can easily check all
of your named ranges with the Name Manager to make sure they are
including all of the data.
To create a data validation drop-down list
(Excel 2007-2019):
1. Select the cell where you want the drop-down list to appear. In our
example, that's cell E6 on the Invoice worksheet.
2. On the Data tab, click the Data Validation command.
2. A dialog box will appear. Click Select data range in the Criteria: field.
3. Select the data that will appear in the drop-down list, and then click OK.
In our example, the shipping options are stored in cell range A2:A4 on
the Shipping worksheet, but we'll select A2:A10 (we're including empty
rows just in case more shipping options are added later on).
There we go—with our new data validation drop-down list, it'll be a lot harder for
someone to break our function in the future!
“Watch the video link below to learn about
Vlookup Function.”
LINK: https://youtu.be/ODZfwD39gGE
LINK: https://youtu.be/y8ygx1Zkcgs
Goal Seek
Whenever you create a formula or function in Excel, you put various parts together
to calculate a result. Goal Seek works in the opposite way: It lets you start with
the desired result, and it calculates the input value that will give you that result.
We'll use a few examples to show how to use Goal Seek.
In the image below, you can see that the grades on the first four assignments
are 58, 70, 72, and 60. Even though we don't know what the fifth grade will be, we
can write a formula—or function—that calculates the final grade. In this case, each
assignment is weighted equally, so all we have to do is average all five grades by
typing =AVERAGE(B2:B6). Once we use Goal Seek, cell B6 will show us the
minimum grade we'll need to make on that assignment.
1. Select the cell with the value you want to change. Whenever you use
Goal Seek, you'll need to select a cell that already contains
a formula or function. In our example, we'll select cell B7 because it
contains the formula =AVERAGE(B2:B6).
2. From the Data tab, click the What-If Analysis command, then
select Goal Seek from the drop-down menu.
3. A dialog box will appear with three fields. The first field, Set cell:, will
contain the desired result. In our example, cell B7 is already selected.
The second field, To value:, is the desired result. In our example, we'll
enter 70 because we need to earn at least that to pass the class.
The third field, By changing cell:, is the cell where Goal Seek will place
its answer. In our example, we'll select cell B6 because we want to
determine the grade we need to earn on the final assignment.
4. When you're done, click OK.
5. The dialog box will tell you if Goal Seek was able to find a solution.
Click OK.
6. The result will appear in the specified cell. In our example, Goal Seek
calculated that we will need to score at least a 90 on the final
assignment to earn a passing grade.
To use Goal Seek (example 2):
Let's say you're planning an event and want to invite as many people as you can
without exceeding a budget of $500. We can use Goal Seek to figure out how many
people to invite. In our example below, cell B5 contains the formula =B2+B3*B4 to
calculate the total cost of a room reservation, plus the cost per person.
1. Select the cell with the value you want to change. In our example, we'll
select cell B5.
2. From the Data tab, click the What-If Analysis command, then
select Goal Seek from the drop-down menu.
3. A dialog box will appear with three fields. The first field, Set cell:, will
contain the desired result. In our example, cell B5 is already selected.
The second field, To value:, is the desired result. In our example, we'll
enter 500 because we only want to spend $500.
The third field, By changing cell:, is the cell where Goal Seek will place
its answer. In our example, we'll select cell B4 because we want to
know how many guests we can invite without spending more than $500.
4. When you're done, click OK.
5. The dialog box will tell you if Goal Seek was able to find a solution.
Click OK.
6. The result will appear in the specified cell. In our example, Goal Seek
calculated the answer to be approximately 18.62. In this case, our final
answer needs to be a whole number, so we'll need to round the answer
up or down. Because rounding up would cause us to exceed our
budget, we'll round down to 18 guests.
As you can see in the example above, some situations will require the answer to be
a whole number. If Goal Seek gives you a decimal, you'll need to round up or
down, depending on the situation.
Document Inspector
Whenever you create or edit a workbook, certain personal information may be
added to the file automatically. You can use Document Inspector to remove this
information before sharing a workbook with others.
Because some changes may be permanent, it's a good idea to save an additional
copy of your workbook before using the Document Inspector to remove information.
Marking a workbook as final will not prevent others from editing it. If you want to
prevent people from editing it, you can use the Restrict Access option instead.