Page 1

Cool Excel Tips & Tricks (PACRAO 2010)


Let’s Get Started • Why am I standing up here? • Who are you? • What am I going to teach you?

Cool Excel Tips and Tricks:

Pivott T Pi Tables, bl F Formulas, l C Calculated l l t d Fi Fields, ld Data Merges, and More

Debi Tuttle Lead Analyst for Student Information Systems, California Institute of Technology 2

Freeze! And Filter

Protection and Encryption

• Freeze panes: keep key information in view all the time. Location: View ribbon, Window group.

• Protect (sheet, workbook): prevent other people from messing around. Password is optional. Available on Review ribbon > Changes group. • Encrypt E ((workbook): kb k) prevent other h people l from opening the file. Password is required. Available on Office button > Prepare > Encrypt Document.

• Filter: narrow the results using selected criteria. Location: Home ribbon, Editing group (under Sort & Filter) or Data ribbon, Sort & Filter group.

Caveat: Excel encryption is not terribly secure. A dedicated thief could crack it easily. But it’s a reasonable way to prevent snooping. 3



Getting Functional

• When creating formulas, break things down into small pieces, then put everything together. • This helps you verify each individual step along the way. • Nested formulas are your friend!

There are several ways to invoke functions: • On the Formulas ribbon, the large Insert Function (fx) button will bring up a dialog box. • Also on the Formulas ribbon, commonly-used functions are grouped by area. • In any cell, typing an equals sign (=) will activate a pull-down list of recently used functions. • There is also a small Insert Function button (fx) on the aptly-named formula bar. 5

Debi Tuttle, Caltech (



Cool Excel Tips & Tricks (PACRAO 2010)


Manipulating Text

Manipulating Text, Task #1

Task #1: Turn separate all-uppercase name fields into a standard lastcomma-first-middle initial format in title case.

• Step 1: Convert full middle name into a middle initial using LEFT. =LEFT(C2,1)



Number of characters to take from the left


Manipulating Text, Task #1


Duplicating Formulas • Drag the lower-right corner of any formula field to an adjacent cell to duplicate the formula; Excel will try to increment the cell numbers accordingly. • Click inside the function on the formula bar to display which cells are being referenced.

• Step 2: Convert last name and first name into title case using PROPER. =PROPER(A2) LAST_NAME field



Manipulating Text, Task #1

Manipulating Text, Task #1

• Step 3: Put all the pieces together using CONCATENATE.

• Step 4: Get rid of extra spaces using TRIM.




Debi Tuttle, Caltech (



Cool Excel Tips & Tricks (PACRAO 2010)


Duplicating Formulas, Part 2

Formulas or Values?

You can copy a formula all the way down the column in a couple of ways. • Grab the lower-right corner and just drag down until you get to the bottom. Thi gets very tiresome This i if you h have thousands of rows. • Select the formula cell. Double-click on the small square in the lower-right corner. (Note: must be adjacent to existing data block.)

• Depending on what you eventually are going to do with the data, you might choose to save the formulas or the ( ) results of the formula (values). • Formula: the source data will be changing and you want the results of your formula to update automatically. • Values: you are going to transfer the information to another location. 13


Paste Special

Manipulating Text, Task #2

• By default, the formula will be pasted. To get around this, do the following: • Go to the destination for the paste, then right right-click click and select Paste Special. • Select “Values” and click OK. • Now the formula is gone.

Task #2: Deconstruct the last-firstmiddle field we just created into its various parts. Functions used: FIND, LEFT, LEN, RIGHT, MID, IF You could also use Text To Columns (Data ribbon) but you need to be careful of compound names that contain spaces. Important! When doing this type of formula, the data must be in a consistent format. 15


Manipulating Text, Task #2

Manipulating Text, Task #2

Step 1: Use FIND to determine the location of the first comma. =FIND(",",A2,1)

To get the first name and middle initial we could use RIGHT or MID. Either way way, we’re we re going to start with:

Step 2: Use LEFT to pull out the last name only. =LEFT(A2,FIND(",",A2,1) – 1)

Step 3: Use LEN to determine the total length of the name string. =LEN(A2) 17

Debi Tuttle, Caltech (



Cool Excel Tips & Tricks (PACRAO 2010)


Manipulating Text, Task #2

Manipulating Text, Task #2

Step 4: Use RIGHT to pull out the first name and middle initial. =RIGHT(A2,LEN(A2) – FIND(",", A2,1)-1) FIND( A2 1) 1) Or Step 4: Use MID to pull out the first name and middle initial. =MID(A2,FIND(",",A2,1)+2, LEN(A2))

Step 5: To create the first name, use IF to determine if there is a middle initial (in this case, if the second character g is a space). p ) If yyes,, then from the right use LEFT and LEN to trim off the initial. If no, then return the whole name. =IF(MID(F2,LEN(F2)-1,1) = " ", LEFT(F2,LEN(F2)-2),F2) 19


Manipulating Text, Task #2

Is it Text or a Number?

Step 6: To create the middle initial, use IF as before. Then use RIGHT to get the middle initial if it exists. =IF(MID(F2,LEN(F2)-1,1) IF(MID(F2,LEN(F2) 1,1) = " ",, RIGHT(F2,1),"")

• Excel can store “numbers” as either text or true numbers. • True numbers are right-justified by default. • Numbers stored as text will be leftjustified by default, and Excel will show a Smart Tag (little green triangle).

Tip: you can bring up the Function Arguments dialog by placing your cursor on the function name in the formula bar and pressing the Insert Function button (fx). 21


Converting Text to Numbers

Statistical Analysis in Excel

• Quickest way: use Paste Special. Select “Values” and “Add” (under Operation). You’re actually adding g zero to everyy number and converting to a true number in the process. • Another way: use the VALUE function (in the Text functions group). =VALUE(J2)

• Caveat: Excel is a spreadsheet application. It can do fairly sophisticated statistics, but if you have SPSS,, STATA,, or some other dedicated statistical software package, use that (if you know how). • That being said, Excel can do a lot in a pinch.

Tip: use VALUE if the source data might change. 23

Debi Tuttle, Caltech (



Cool Excel Tips & Tricks (PACRAO 2010)


Array Functions

Naming a Range

• Statistical functions work with arrays of data. • It’s usually easier to set up your arrays as named ranges, especially if you you’re re going to perform several functions on the same array.

• Select the range of cells you want to name. Then do one of the following: • On the Formulas tab in the Defined Names g group, p, select “Define Name” OR • Right-click and select “Name a Range.”

• To review all the named ranges you’ve defined, click on the Name Manager on the Formulas tab. 25


Basic Statistics

Merging Data

Average/Mean: =AVERAGE(GPA_ARRAY) Median: =MEDIAN(GPA_ARRAY) Mode: =MODE(GPA_ARRAY) Standard Deviation: =STDEV(GPA_ARRAY) 25th Percentile: =PERCENTILE(GPA_ARRAY,0.25) 75th Percentile: =PERCENTILE(GPA_ARRAY,0.75)

• In order to merge two datasets, you will need to have at least one piece of information in common (e.g., a q campus p student ID). ) unique • The two fields need to be the same type (usually number or text). • You may need to manipulate the fields to get them to be exactly the same. 27




• When you have two datasets that should contain identical records, you can use EXACT to verify the match. • The datasets must be in the same order. If you are using text fields for ordering, beware of uppercase vs. lowercase ordering. • EXACT will return TRUE or FALSE.

• Step 1: Get both datasets in the same order. • Step 2: Paste one dataset next to the other, leaving at least one empty column between them. • Step 3: Use EXACT to compare the two columns of interest. • Step 4: Adjust data as necessary and perform the comparison again. 29

Debi Tuttle, Caltech (



Cool Excel Tips & Tricks (PACRAO 2010)




• VLOOKUP is useful for merging unequal datasets and also for performing text lookups and transformations. • The data do not need to be in order. • You have to set up your data properly in order for the function to work. • Use named ranges to make things easier.

Step 1: On the source worksheet, make sure that the column that contains your matching field is all the way on the left. THIS IS CRITICAL. Step 2: Set up a named range in your source worksheet. The range should contain the matching field as well as any data you want to pull into the destination. 31




Step 3: In the destination worksheet, set up the VLOOKUP function.

Step 4 (optional): Use IF and ISNA to handle missing values.

The named range in the source worksheet.

Type FALSE to ensure an exact match.

=IF(ISNA(VLOOKUP(A2,HighSchools, =IF(ISNA(VLOOKUP(A2 HighSchools 3,FALSE)),"No High School Found", VLOOKUP(A2,HighSchools,3,FALSE))

=VLOOKUP(A2,HighSchools,3,FALSE) The column that contains the matching field.

The number of the column (in the source worksheet) that contains the data you want to display.

Tip: There are several other functions that test for various conditions. They are found under More Functions > Information. 33


Another Use For VLOOKUP

Creating Pivot Tables

• VLOOKUP can be used to “translate” coded fields into plain English (e.g., W = White; A = Asian). • Set up a mapping table on another worksheet and use it as your source. • Follow the same directions as the previous example.

• To create a pivot table, place your cursor in any cell of your data, then go to the Insert ribbon > Pivot Table. Excel will automaticallyy select all contiguous filled cells. • You could also type in any named range you’ve defined. Tip: Use F3 to pull up the list of all named ranges you’ve defined. 35

Debi Tuttle, Caltech (



Cool Excel Tips & Tricks (PACRAO 2010)


Arranging Pivot Tables

Changing the Summarization

• Excel 2007: drag and drop fields into the Field List, not the pivot table. • If you prefer the old way: Right-click anywhere in the pivot table and select PivotTable Options. Go to Display tab and check “Classic PivotTable layout.” But you will not be able to take advantage of some of the newer pivot table features in this mode.

To change the pivot table summarization being performed, you can either: • Right-click g in the data area of the table, b , select Summarize Data By, and then select your desired summarization, or • In the Field List, access the dropdown list of the appropriate field name, select Value Field Settings, and then select your desired summarization. 37


Changing Sort Order

Field Settings

• By default, items will be ordered alphabetically. You can set a manual order by clicking and dragging the item name. • Select the item name and then move the cursor carefully over the border of the cell until the it changes to a fourdirection arrow. Then click and drag to the desired location.

• For each row or column category, you can right-click and access “Field Settings.” • On the Layout & Format tab, select “Show items with no data” to always display all values in the list. Tip: If you want to display a value that doesn’t exist in your data set at all, type it at the bottom of your dataset, but leave the column you’re counting blank. You may need to adjust the data source to include the new line. 39


Pivot Table Options

More Pivot Table Options

• To give custom labels to row or column categories, select the cell and type text in the formula bar. • To remove the row and column headers, on the Pivot Table Options bar, click the Field Headers button in the Show/Hide group. (Caution: this will also remove the dropdown filter buttons.)

• If there are no values in a cell, by default the cell will be blank. You can specify a default value for empty cells. g and select Pivot Table Right-click Options. On the Layout and Format tab, enter your value for empty cells. • When you have time, explore what other Pivot Table Options are available here. 41

Debi Tuttle, Caltech (



Cool Excel Tips & Tricks (PACRAO 2010)


Pivot Table Design

Re-using a Pivot Table

On the Pivot Table Design tab, you have many choices:

• If you want to re-use a pivot table, you can copy the table and paste it somewhere else (Pivot Table Options tab > Select > Entire PivotTable); then change h the h d data source (Pi (Pivot T Table bl Options tab > Change Data Source). • Obviously, the column names and data types must be the same between the two sources.

• • • • •

PivotTable Style Banded rows and columns Blank lines between items Subtotal location (top vs. bottom) Report layouts (compact, outline, or tabular) • Grand Totals 43


Other Pivot Table Tricks

Calculated Fields

• Display percentages and differences by using Value Field Settings > Show values as. p to organize g categories. g Pivot • Use Groups Table Options > Groups. • Use a PivotChart to get a visual representation of your data. Pivot Table Options > PivotChart. The PivotChart will update as you modify the underlying PivotTable.

• Calculated fields operate on summarized pivot table data. • To create a calculated field: PivotTable Options ribbon > Formulas > Calculated Field. Tip: When you have multiple items in the Values area, you can stack them vertically by moving the “∑ Values” item from Column Labels to Row Labels. 45


Filter & Sort in Pivot Tables

Random Sampling

• The regular Excel filter buttons will not work inside pivot tables. You can filter pivot tables by Label (typically yp y numbers). ) text)) or byy Value ((typically Use the dropdown menu on the Row or Column labels and select Label Filters or Value Filters. • Right-click on any column in the Values area to access the Sort menu.

• Use the RAND function to assign everyone a random number between zero and one. • Sort the list on the random number column. • Take how ever many rows you need for your sample from the top. • RAND will recalculate when you sort, but that doesn’t matter. 47

Debi Tuttle, Caltech (



Cool Excel Tips & Tricks (PACRAO 2010)


Calculate Age

Text Import Wizard

• DATEDIF is a very useful but undocumented function that calculates time intervals between two dates. • You will need to type it because it isn’t available from the function list (!). • Instructions and examples:

When importing a comma-delimited text file with a .CSV extension, Excel does not invoke the text import wizard, and you can’t control if columns are set as text or number or date. date To get the wizard, wizard either: • Change the file extension to .TXT, then open the document. This will open the file in a new document. • Go the Data ribbon and click the “From Text” button. This will insert the file into your current workbook.



Customize Your Workspace

Learning More about Excel

• The Quick Access Toolbar: Office Button > Excel Options > Customize

• • • •

Search/browse the function list Use Excel Help Buy a book S Search h online li




crime is so great as daring to excel.”

Question Time!

-- Winston Churchill Thank you for your time. I hope you learned something useful! Debi Tuttle 53

Debi Tuttle, Caltech (



D1 coolexceltipsandtricks