2015 County Auditors Institute May 2015 Excel Workshop Tips Working Smarter, Not Harder by David Scott, SpeakGeek@att.net Note: All examples in this workshop and this tip sheet were done using Excel 2010 for Windows. Concepts presented also apply to earlier and later versions of Excel or Excel for the Mac but may differ in appearance. Data Tables and Subtotals To function properly and to keep column headings from being sorted into the data, the column headings of a data table should be in one row, each heading should be unique (at least one character different in each heading title) and formatted differently. An easy way to format heading row differently is to select the row and make the text bold. Adding additional formatting, such as different font face, colors, or alignment, are optional. Do not use the Home tab's "Format as a Table" icon because it will (paradoxically) turn off the ability to do Subtotals! Each column should consistently contain the same type of information numbers, dates, text, or percentages. There may be blank cells in the table but not blank rows or blank columns. A blank row or column indicates the end of the table. To select the table to work with, the cell pointer must be somewhere in the table. If there is a blank row or column, the entire table must be manually selected. To sort one or more columns, use the tool found at the right side of the Home tab's ribbon or the tool found on the Data tab's ribbon.
Single columns may be sorted using one of the tools found on the Home or Data ribbons. To sort multiple columns, use the Custom Sort option in the Home tab's Sort & Filter tools or the tool found on the Data tab's ribbon. When doing a multi-level sort, be sure it has detected that your data table has headers. The check box at the top right corner should have a check mark in it. The multi-level sort tool sorts by the first level, then sorts within that level by the next column specified in the Order as chosen. Levels may be added into the list by clicking on the row where the level is to be added. Deletions are done by selecting the row to be deleted, then deleting it. You may move a level up or down using the elevator buttons to the right of the Copy Level button. Once the data is sorted in the groupings you desire, you can now do a Subtotal. The tool is located on the right end of the Data tab's ribbon. Do not let the name of the Subtotal tool fool you. It does much more than that. You can find the Sum, Count, Average, Maximum value, Minimum value, Product, Standard Deviation, Variance, and several variations of these functions. David M. Scott 2012, 2015 version 2014-05-4 Page 2 of 12 CAI 2015 Excel Workshop
The example at right is summing the amount for each FY (Fiscal Year) and inserting the subtotal under the Amount column and a grand total Summary at the bottom of the data table. Additional groupings with totals, counts, etc., may be added but if you want to keep any previously inserted subtotals, counts, etc., you must uncheck the "Replace current subtotals" option near the bottom of this dialog box. If you want to have each grouping printed on a separate page, you may check the "Page break between groups" option. If you have two columns you wish to Sum, you can check both columns and they will be subtotaled on the same row at the same time. The example at left will add a Count for each FY group created by the Subtotal in the example above, and put the count amount below the Transaction column on a separate row. Note that the "Replace current subtotals" box is unchecked. If it was checked, the Sum(s) done in the previous pass would be removed and replaced with the Subtotal(s) specified in the second pass described in the dialog box at left. If the inserted row with the Subtotal(s) has a cell that looks like (what I call "railroad tracks") this means the width of the column is narrower than the width of the number in the cell using the number format of that cell. To adjust the column width, move your mouse pointer to the right side of the column that needs adjusting and either do a double-click to "Autofit" the column width to the widest content in the column for the entire worksheet or hold down the left mouse button and drag the column to the width you desire. Note: If you make a mistake, do not use the Excel Undo command button. This will completely remove all Subtotal additions you have made and take it back to a plain data table. David M. Scott 2012, 2015 version 2014-05-4 Page 3 of 12 CAI 2015 Excel Workshop
Once the Subtotals are inserted, three or more buttons are added in a column to a new panel to the left of the worksheet. These allow you to control the levels of detail displayed. Displays only the Grand Totals Displays the first Subtotal level created and subsequent buttons display each additional Subtotal level added. The last button shows all Subtotal levels and the original data table rows with the data records The and buttons in the Outline pane on the left allow you to collapse or expand specific groups and levels rather than the entire group and level. This is handy for displaying details of one or more groups while hiding all but the totals for others. Like the column and row buttons on the Frame, the outline panel to the left of the worksheet does not print when the worksheet is printed. (You can print the column and row headings if you click on the Column and row headings checkbox on the Sheet tab of the Page Setup dialog box. Using the outline to the left and/or adding additional Subtotal levels, it is easy to look at various groupings and levels. Unlike adding rows and formulas manually, Subtotals are easily modified. David M. Scott 2012, 2015 version 2014-05-4 Page 4 of 12 CAI 2015 Excel Workshop
When done, the subtotals may be saved as part of the worksheet or they may be removed by using the Data tab's Subtotal tool button to open the Subtotal dialog box. At the bottom of the dialog box is the button which, with one click, will remove all sums, counts, etc., and the outline pane and return everything to the sorted table you had before you used the Subtotal tool. Rounding Does 2 plus 2 equal 5? Well, perhaps for large values of 2. It is not uncommon for spreadsheets with calculations, particularly those using percentages or division, to have sums that do not add up to expected values. This is because what you see as a value in the spreadsheet may not be whole story. Formatting may be limiting the number of decimal places visible, masking a number that has significant digits to the right of the decimal place. One of the best ways to avoid inaccuracies is the proper use of rounding. Excel has several functions to round values. The most common and obvious is the Round function. Others are RoundUp, RoundDown, and the newcomer MRound. Of course, there may be reasons other than cumulative calculation errors. Excel only stores 15 digits in a cell. If entries or calculations result in more than 15 significant digits, the number is truncated and, by default, expressed in scientific notation format. David M. Scott 2012, 2015 version 2014-05-4 Page 5 of 12 CAI 2015 Excel Workshop
All four rounding functions share the pretty much the same syntax: =FunctionName(Number,Digits) Where: FunctionName is the rounding function chosen (Round, RoundUp, RoundDown, MRound). Number is the number, cell address, or a calculation resulting with a number. Digits is the number of digits you wish to round to. A positive number is the number of digits to the right of the decimal place and a negative number is the number of digits to the left of the decimal place. However, in the case of MRound, Digits is the desired multiple to round to. Below are examples of the rounding functions. In each case, the cell containing the formula is formatted to three decimal places so the result of the rounding is visible but the value is rounded to two decimal places. The first illustration shows the cell contents and the second illustration shows the resulting values in a normal view. Round, RoundUp, RoundDown functions As Commonly Used David M. Scott 2012, 2015 version 2014-05-4 Page 6 of 12 CAI 2015 Excel Workshop
Using a negative value for the Digits portion of the formula's syntax rounds to the left of the decimal. This allows for rounding to tens, hundreds, thousands, millions, etc. This can be handy in cases where to-the-dollar precision is not needed. Round, RoundUp, RoundDown functions when dollars are big and precision is small David M. Scott 2012, 2015 version 2014-05-4 Page 7 of 12 CAI 2015 Excel Workshop
Another function, called MRound, is similar in nature and helps to round a value to the nearest multiple of a number using the standard rule of rounding up if 5 or greater and down if less. In other words, 106 rounded to a multiple of 5 round down to 105; rounded to a multiple of 10 would be 110; and rounded to a multiple of 100 would be 100. Any Digit may be used as a multiple. (MRound was introduced in Excel 2003 but it required the installation of the Analysis ToolPak add-in. It is standard in later versions.) MRound helpful if rounding to multiples. Example uses a multiple of 4. Other math functions that could be helpful with decimal numbers include: =INT(number) which rounds a number down to the nearest integer. =TRUNC(number, num_digits) which truncates a number to an integer by removing the decimal part of the number =QUOTIENT(numerator, denominator) which returns the integer portion of a division. David M. Scott 2012, 2015 version 2014-05-4 Page 8 of 12 CAI 2015 Excel Workshop
IF Function One of the most popular and useful worksheet functions after the Sum function is the IF function. It is categorized as a Logic function and has several variations. The function does a test and, based on the outcome of the test, does one of two actions. If more than one test is needed to determine the outcome, the expression could become nested (multiple functions and calculations imbedded into the primary function's argument) or the logic functions OR and/or AND could be used within the test portion of the argument. The syntax for the If function is: =IF(Logical_Test, Value_If_True, Value_If_False) Where: Logical_Test is a value or expression or criteria that can be evaluated as true or false (yes or no). Value_If_True is the value or action to be taken or the calculation if the Logical_Test evaluates to TRUE Value_If_False is the value or action to be taken or the calculation if the Logical_Test evaluates to FALSE Value_If_True and Value_If_False are optional portions of the syntax. If omitted, the function returns the values of TRUE and FALSE respectively. If text is used as the result in the Value_If_True or the Value_If_False portions, the text must be enclosed in double quotes. For example, if the value in cell A10 is 100 and the expression is: =IF(A10>100, "Value greater than 100","Value less than or equal to 100") David M. Scott 2012, 2015 version 2014-05-4 Page 9 of 12 CAI 2015 Excel Workshop
IF a simple use In the following example, a 10% discount is applied if the amount is greater than 500. Note that the express is for values greater than 500. If it is exactly 500, it does not pass the test and is evaluated as false. David M. Scott 2012, 2015 version 2014-05-4 Page 10 of 12 CAI 2015 Excel Workshop
Testing a value not contained in the True or False elements In some cases, it might be more powerful if the Logical Test refers to a value elsewhere in the worksheet. This allows the calculations to dynamically update as the value changes. In the following example, the test is done on the value in the Apply Discount? Column, the value that may be discounted is in the Value column and the discount amount is in the cell F3. The expression evaluates to see if a discount is to be applied and, if it should be applied, multiplies 1 minus the discount percentage times the value. The cell address for the Discount the formula uses an Absolute Cell Address that "locks-in" the cell address and does not allow it to change when copied. An Absolute Cell Address uses a "$" before the column letter and another before the row number to keep the cell address value locked. A cell reference that locks only the column or row portion of a cell address is called a Mixed Cell Address and the standard one that has no "$" in any portion of the cell address is called a Relative Cell Address. David M. Scott 2012, 2015 version 2014-05-4 Page 11 of 12 CAI 2015 Excel Workshop
IFs, ANDs, and ORs Sometimes it takes more than one test or criteria to determine if the result is true or false. In the example below, the AND and OR functions are combined with a series of tests. Note the AND or OR function is before a parenthetical series of tests and is not used between the tests as it would be if written in English. These examples show only two tests but multiple may be used. The limit is the number characters in the cell cannot exceed 32,767 characters. Only the first 1,024 characters may be displayed in the cell but the entire 32,767 may be displayed in the Formula Bar (Excel 2010). In the example below, the words Yes or No appear depending on the outcome of the test. If the result appearing like a blank cell is preferred instead of the word No, the "No" in the False portion of the formula expression may be changed to "" two quotes without anything between them. David M. Scott 2012, 2015 version 2014-05-4 Page 12 of 12 CAI 2015 Excel Workshop