AdvancedTopicsInExcel PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Advanced Topics in Excel

Designed by Jason Wagner, Course Web Programmer, Office of e-Learning

DEFINED NAMES ............................................................................................................................... 1  

DATA VALIDATION ........................................................................................................................... 1  

PROTECTING SPREADSHEETS ......................................................................................................... 2  

LOOKUP TABLES ............................................................................................................................... 2  

CONDITIONAL FORMATTING WITH RULES ................................................................................... 3  

CONDITIONAL FORMATTING WITH COLOR SCALES.................................................................... 3  

LINKING TO EXTERNAL SOURCES ................................................................................................... 4  

PIVOTTABLES .................................................................................................................................... 5  
DEFINED NAMES
Suppose you are performing a lot of calculations on a large data set. It can be time consuming to reference this
data set every time you wish to use it.

So suppose we have 200 SAT scores and we are going to be doing calculations on it. We can define it to a name
to make it easier to call in function. Under the Formulas ribbon, in the Defined Names group, select Defined
Name. In the name, enter SATScores. Under refers to, select cells A1 through A200.

Click OK. Now, let’s calculate the average and standard deviation. In cell D1, enter the formula
=AVERAGE(SATScores). Then, in cell D2, enter the formula =STDEV(SATScores). You will see that this has
performed the calculations for us using the defined names.

DATA VALIDATION
When you create a spreadsheet that uses calculations, it is likely going to be possible to “break” it. For example,
as we saw earlier, if you do a mathematical calculation on a cell with a string, it causes a value error.

Let’s revisit the average speed calculator example we looked at earlier. For the distance, we can allow any number
greater than or equal to zero. For the time, we can allow any number greater than zero. (We cannot allow zero or
we will get a division by zero error.

Select cell B1. Then, under the Data ribbon, in the Data Tools grouping, select data validation. Under Allow, pick
Decimal. Then, under Data, pick greater than or equal to. Finally, for Minimum, enter 0.

Advanced Topics in Excel | Page 1


Click OK. Now, type in a number into the cell. We’ll see that our calculator works. However, if we try to type in a
word, or a number less than zero, we get an error dialog.

PROTECTING SPREADSHEETS
Continuing with our average speed calculator example, let’s say we were going to distribute this and we don’t
want people to change the formulas or layout of the spreadsheet, but we don’t want to lock them out completely
of changing values (otherwise, they can’t use the calculator).

First, select the two cells that we want to allow input into and open the Format Cells dialog. Then, under the
Protection tab, make sure Locked is unchecked. Click OK.

Click OK. Now, click on the Review ribbon, and in the Changes group, select Protect Sheet. Enter a password to
lock the sheet with, and click OK. You will be prompted to enter the password for a second time. Now, try to edit
the two input cells. You will see that everything works as we expect. However, try editing any other cell. It should
give you an error dialog.

LOOKUP TABLES
Sometimes, you may need to create a lookup table. A lookup table allows you to “lookup” one value to get one
or more other associated values. Consider the example of a calculating a student’s final grades. In this case, we
have grades of 94 and higher translating to a 4.0; 88 and higher to a 3.5; 82 and higher to a 3.0; and so on.

In this case, we will use the VLOOKUP() function. VLOOKUP takes three arguments:

• The value you are looking up (example: The student’s final average, in column C)
• The cells containing the lookup table (example: F2:G9)
• The column of the lookup table that we want displayed in the cell (example: 2)

So, in cell D2, our formula will be =VLOOKUP(C2, F$2:G$9, 2). Note that we used absolute references in the
table so that the rows do not change when we drag the cells down.

Advanced Topics in Excel | Page 2


Now, copy cell D2 down through the rest of the student records. It should fill in all of the grades. To
demonstrate, let’s suppose we wanted to lower the minimum score for a 3.5 from an 88 to an 84. If we change
this value in the lookup table, we can see that Gossamer’s grade changes from a 3.0 to a 3.5.

CONDITIONAL FORMATTING WITH RULES


You can automatically format text based upon the value. Returning to our grade book example, suppose you
wanted to highlight all final averages that were less than the average of the class. To do this, highlight all of the
cells with grades in column C. Under the Home ribbon, in the Styles group, select Conditional Formatting, and
in the menu, choose New Rule. Under Select a Rule Type, select Only cells that contain. Under Format only
cells with, choose Cell Value, less than, and for the formula, enter =AVERAGE(C2:C13). Then, click the
Format… button and change Color to red. The dialog window should look like this:

Then, click OK. The grades less than the average of 81.3 should now be highlighted in red.

CONDITIONAL FORMATTING WITH COLOR SCALES


Let’s say we wanted to take this example a step further. For our final grade column, suppose we want to
progressively color everything. We would like a 2.0 to be yellow for “caution”. Then, anything less than 2.0
progressively gets more redder (“bad”) the lower it is to 0.0, and anything greater than 2.0 gets progressively
greener (“good”) the closer it is to 4.0.

Advanced Topics in Excel | Page 3


To do this, highlight all of the grades in the final grade column. Under the Home ribbon, in the Styles group,
select Conditional Formatting, and in the menu, choose the first icon (green on top, yellow in the middle, red on
the bottom) under color scales. It should now look like this:

This is close to what we want, but there are two problems:

• By default, the “reddest” is the minimum value, and the “greenest” is the maximum value. This will throw
our scale off if we do not have a 0.0 and 4.0 in our class.
• By default, the middle “yellow” value will be the median number in the data set. We want this to be a 2.0.

While all of the grades under the final grades column are selected, go to the Conditional Formatting button
again, and this time, select Manage Rules. Then, click on the rule we have set and click Edit Rule. At the bottom,
where it has the three Values across (just above the gradient image), change it so the Type for all three is
Number. Then, set the Values to 0.0, 2.0, and 4.0, respectively. It should look like this:

Click OK. Our scale should have changed to what we are looking for.

There are similar feature to do the same thing with data bars and icons.

LINKING TO EXTERNAL SOURCES


If you have a CSV file that is updated, you can dynamically link to that file. To do this, go to the Data ribbon, in
the Get External Data group, select From Text. Then, open the file demo_enroll_1.csv. Click Next, and then
change the delimiter from Tab to Comma. Click Finish. Then, select New worksheet, and click OK. Then,
rename the sheet to something more memorable, such as EnrollCSV.

Advanced Topics in Excel | Page 4


Let’s load these into our targets example. Under the column for current number of students, we are going to
reference each cell just to load its value. For example, in cell B2, we will put the formula =EnrollCSV!B2.

Now, suppose a week has passed and we want to load the data. Under the Data ribbon, go to the Connections
group and click Refresh All. A dialog will popup. Open the file demo_enroll_2.csv. We will see that the data
values update.

PIVOTTABLES
PivotTables allow you to easily take large amounts of data and aggregate them.

For example, consider the case where we want to know how many courses were offered in each department that
were face-to-face (F2F), hybrid (HYB), or online (WEB).

First, we need to click anywhere inside our table of data. Then, go to the Insert ribbon, and click the first button,
PivotTable.

When the dialog box pops up, the default settings should be as shown below. Be sure New Worksheet is
selected. Click OK.

Advanced Topics in Excel | Page 5


Now, we should have a box for our PivotTable inside our worksheet, and a new pane over on the right hand-side
of the screen.

From here, we simply need to visualize how we want our PivotTable to look. First, let's create a PivotTable that has
a list of course subject codes down the left-hand side of the screen, and the three delivery formats (F2F, HYB, and
WEB) as columns. We are going to want to know how many courses are in each.

To build this PivotTable, we are going to arrange the fields exactly as we want our final product to look. In the
pane on the right hand side of the screen, we are going to click the SUB field in the list of fields at the top and
drag it down to the Row Labels box. You will see the worksheet update with all of the subject codes.

Next, we want to see the delivery method as the columns. In the pane on the right, click the DEL field and drag it
down to the Column Labels box.

Advanced Topics in Excel | Page 6


Now we have our PivotTable arranged as we want the data to appear, and we just need to add our data to it.
Because we want to create a count of the number of courses for each delivery method and each course, we are
going to use the CRN field, as every course has a unique CRN. We are going to drag this CRN field down to the
Values box in the pane on the right.

We see it has added the data to our PivotTable, but it added the sum of the CRNs. We want to know how many
CRNs there are. In the pane on the right, in the Values box, click the icon with the downward pointing arrow next
to Sum of CRN. Then, select the Value Field Settings... option.

Advanced Topics in Excel | Page 7


Under Summarize value field by, select Count and click OK. We can see that the PivotTable has been updated
with accurate counts. Totals have automatically been calculated both by subject code and by delivery type.

Now, suppose we want to know how many credits were offered. In the Values box in the right pane, simply click
on Count of CRN and drag it out of the pane. Now, click the CR field and drag it down into the Values box. It,
by default, will show a Count of CR. Using the directions above, open the Value Field Settings window to
change it to Sum of CR. We can see our table has updated.

Advanced Topics in Excel | Page 8


Now, suppose we want to look at this list differently, and we want only one column of numbers. On the left, we
want each subject code listed in a row, with the number of each delivery method listed below it.

All we need to do to accomplish this is, in the right pane, drag the DEL field from the Column Labels field to the
Row Labels field.

Now, suppose we want to know not only how many credits were offered, but also home many courses as we
originally had. Follow the directions above for adding the Count of CRN to Values box, but do not remove the
Sum of CR from the Values box. This puts additional data on our table.

Advanced Topics in Excel | Page 9


Finally, let's suppose rather than seeing first by subject code and then delivery method that we want to see the
data first by delivery method, and then by subject code.

To do this, we are going to simply go into the Row Labels box, and click on the SUB field, and drag it down so it
is below the DEL field. Note that a gray line will appear as you drag it to show where it will fall when you release
the mouse.

One thing to note is you don't need rebuild the PivotTable if your data changes. If you update the data on the
original worksheet, you can click anywhere inside the PivotTable on the tab it was created in and, under the
PivotTable Tools group of ribbons, select the Options ribbon. Then, click the Refresh button.

Advanced Topics in Excel | Page 10

You might also like