Professional Documents
Culture Documents
Working Smarter With Excel 2007: Tore Søfting
Working Smarter With Excel 2007: Tore Søfting
Working Smarter With Excel 2007: Tore Søfting
2009
Table of contents
Table of contents ..................................................................................................................................... 2 Introduction............................................................................................................................................. 4 What is new in Excel 2007 ....................................................................................................................... 5 News..................................................................................................................................................... 5 New user interface .......................................................................................................................... 5 New file types .................................................................................................................................. 5 New functions ................................................................................................................................. 6 Improved graphics ........................................................................................................................... 6 Conditional formatting .................................................................................................................... 6 The Basics ................................................................................................................................................ 7 Navigation ............................................................................................................................................ 7 Selection ............................................................................................................................................... 7 Smart summing-up ............................................................................................................................... 8 Copying formulas ................................................................................................................................. 8 Adjusting column width (and row height) for multiple columns ......................................................... 9 Automatic cell formatting .................................................................................................................... 9 The right mouse button ..................................................................................................................... 10 List functions ......................................................................................................................................... 11 Freeze column headings .................................................................................................................... 11 Repeat headings on print ................................................................................................................... 11 Sorting ................................................................................................................................................ 12 Subtotals ............................................................................................................................................ 12 Filter ................................................................................................................................................... 13 Advanced filter ................................................................................................................................... 14 Identifying and removing duplicates from a list ............................................................................... 14 Some easy-to.use functions .................................................................................................................. 16 The IF-function ................................................................................................................................... 16 The SUMIF-function ........................................................................................................................... 17 Useful functionality in Excel .................................................................................................................. 18 Validation and protection .................................................................................................................. 18 Validation ........................................................................................................................................... 18 Protection........................................................................................................................................... 19 Output validation ............................................................................................................................... 20 Conditional formatting ....................................................................................................................... 20 Using the IF-function to highlight cells .............................................................................................. 21 Pivot table .......................................................................................................................................... 21 Other useful functions........................................................................................................................... 22 VLOOKUP - Vertical lookup ................................................................................................................ 22 HLOOKUP - Horizontal lookup............................................................................................................ 22 PMT .................................................................................................................................................... 24 SUMPRODUCT ....................................................................................................................................... 24 Array formulas ....................................................................................................................................... 25 Straight array formulas ................................................................................................................... 25 Conditional Array Formulas ............................................................................................................... 25 When should I use array formulas, and when should I use Pivot Tables? .................................... 26 D-functions ............................................................................................................................................ 27 DSUM, DAVERAGE, DMAX,DMIN , etc. .............................................................................................. 27 Other ribbon-based tools. ..................................................................................................................... 28 www.excelkurs.com Page 2
2009
Goal Seek............................................................................................................................................ 28 Solver.................................................................................................................................................. 28 Scenarios ............................................................................................................................................ 30 Consolidation ..................................................................................................................................... 31 Single value and dual value table ....................................................................................................... 32 Importing data from the Internet and from other applications ........................................................ 32 Importing live data from the Internet ................................................................................................ 34 Split cell content................................................................................................................................. 34 Retrieving information from inside a text string................................................................................ 35 Text to columns .................................................................................................................................. 35 Hiding error messages........................................................................................................................ 37 Tracing relations in formulas ............................................................................................................. 38 New and useful features in Excel 2007 ................................................................................................. 39 New functions .................................................................................................................................... 39 Improved graphics ............................................................................................................................. 39 Conditional formatting .................................................................................................................. 40 Graphics rendering ........................................................................................................................ 40 Some keyboard shortcuts...................................................................................................................... 41 Finally how to get help with Excel-problems .................................................................................... 42 The built in help system in Excel ........................................................................................................ 42 Internet resources .............................................................................................................................. 42 Websites............................................................................................................................................. 42 Practice files .......................................................................................................................................... 42 Copyright ........................................................................................................................................... 42
www.excelkurs.com
Page 3
2009
Introduction
Ever since the computerized worksheet was hatched as a concept in the late seventies, and the first worksheet application became commercially available in 1979 (VisiCalc), it has become the foundation for all financial calculation for companies, public institutions and private citizens all over the world. It is indeed hard to fathom advanced calculations without the use of an electronic worksheet. And, with an estimated worldwide market share of around 90%, a worksheet is in most cases an Excel worksheet. This compendium has been developed as a reference tool for Excel training beyond the fundamental level. The content of the compendium mostly follows the progress of the course in its description of the cases. This is no complete textbook for learning Excel; rather, it is a collection of cases for those who are already literate in the basic use of Excel. For those of you who want to immerse yourselves in Excel, there are several excellent books available. I have listed some of these elsewhere in this publication. The various versions of Excel in use today do not differ too much form each other, except for the 2007-version. If you are running Excel 2000, 2002, or 2003, there are only marginal differences. But, if you are running 2007, you know that there are serious differences. The working of the worksheet itself is not much different, but the interface is totally changed. Gone are the menus and the toolbars. In their place we have gotten The Ribbon. The result is that the first few days (or weeks) running 2007 will consist of a lot of searching for the various functions. But having conquered the principles of the placement of functions things should start working very smoothly. And after still more time, one tends to find those earlier versions somewhat old fashioned. Norwegian vs. American/English versions. These two language versions have few problems communication with one another. A model built in a Norwegian version can be opened in an American/English version without any problems, and vice versa. There are two things we should be aware of when typing a formula manually, and that is the use of symbols in the formula, and the names of the functions. The American/English version uses comma (,) to separate sections of the formula, while a Norwegian, or metric European version uses semicolon (;). So, a formula that looks like this SUM(A1:A10,B1:B10) in an American/English version would look like this SUM (A1:A10;B1:B10) in a metric European version. Also, the function names are different, and this has to be taken into consideration when creating formulas in the respective versions. You can download practice files for this compendium from my website, www.excelkurs.com .
www.excelkurs.com
Page 4
2009
News
The new stuff in 2007 can be summed up as: New user interface New file types New functions New functionality New user interface At first sight, the new user interface looks very familiar, symbols and buttons are immediately recognizable, When you start using the program, things tend to become a little more challenging; placement and grouping of the same functions is totally new. The old and familiar toolbars and manu bar has been replaced by what is officially called The Ribbon. There is no simple translation-key you can use to understand the placement of the various functions in Excel 2007. The Office Team has more or less started with clean sheets when designing the new interface. There is only one way to handle the new interface, and that is - of course by working with it and using it. Once familiar with it, the new interface will most likely feel very natural and logical, while the old interface feels exactly that way; old. Microsoft has provided transition applications that show us where functions are located in the new interface. I have linked to these on www.excelkurs,com . Scroll down to the paragraph Office/Excel 2007, and click the links for Excel, Word, PowerPoint and Access!
New file types Office 2007 marks the transition to new and improved file types. The most obvious property of the new file type is the size, typically identical workbooks take up half as much space in 2007-format as they do in 2003-format. Other notable improvements are improved stability, and better provisions for exchanging data with other systems. As usual when new file types are introduced, we have to deal with compatibility challenges vs older Excel versions, meaning that an Excel 2007-file cannot be opened in 2003 without a conversion add-in, and even then new functions and functionality will not work. The only 100% safe way to secure backwards compatibility is to save files in 2003-format from Excel 2007. But, by doing this, we also miss out on the improvements of the 2007-file type. So, it is important to think this through and do the right thing in your organization. Excel 2007 has a built-in compatibility checker, so you will be notified of compatibility issues when you save a 2004-workbook in 2003 file format. The new file types are recognizable on a modified icon, and the new file extension (for standard workbooks), .xlsx (vs .xls in 2003) Another important, and useful, feature in Office 2007, is the ability to save documents in pdf-format. This feature is not activated upon installation of Office 2007, you have to go through an initiation procedure to activate this feature (Office button Save as - Search for other file types). www.excelkurs.com Page 5
2009
Another notable feature of the new file format in Excel 2007 is the size of the sheet: Excel 2003: Excel 2007: 256 columns 16 384 columns 65 536 rows 1 048 576 rows
This is great news for all of you working with analysis of large data volumes, for most others it probably does not matter much.
New functions Excel 2007 is equipped with a number of new functions. The most notable are: Name IFERROR AVEREAGEIF AVERAGEIFS SUMIFS COUNTIFS Description Simplifies handling of error messages in formulas Calculates averages when a condition is met Calculates averages when multiple conditions are met Sums when multiple conditions are met Counts items when multiple conditions are met
Improved graphics Things tend to look better with every new version, and Office 2007 is no exception. Graphical renderings look much better now, making older versions look a little home-made.
Conditional formatting Conditional formatting is a well-known feature from older versions of Excel, and this tool has been extensively re-worked for 2007, providing a vast array of visualization options for your Excel worksheets. Here is an example:
Sales 127 935 202 651 238 567 127 101 192 267 150 504 225 494 162 690 221 378
Sales 127 935 202 651 238 567 127 101 192 267 150 504 225 494 162 690 221 378
Sales 127 935 202 651 238 567 127 101 192 267 150 504 225 494 162 690 221 378
Sales 127 935 202 651 238 567 127 101 192 267 150 504 225 494 162 690 221 378
www.excelkurs.com
Page 6
2009
The Basics
It is very important to use the basic functionality of Excel correctly in order to work rationally. The typical participant on this course is an experienced Excel user who may use the application for quite complicated calculations. However, my experience tells me that the same user does not always use the smartest ways when it comes to the basic functionality of Excel. The following describes a collection of basic techniques that should speed up your use of Excel, even if you are an experienced user.
Navigation
Everybody knows we can click the cursor into any position in the worksheet. Instead of clicking, we may use the keyboard for much quicker navigation. Jump to A1: Wherever the cursor might be located in the worksheet jump to A1 by pressing Ctrl + Home. If we use only the Home command, the cursor moves horizontally to column A
Similarly you can navigate within your tables like this: From B2 to B9 (next break in the series) using Ctrl + (arrow down), and from A6 to G6 (next break in the series), Ctrl (right arrow) This is particularly useful when you have to move the cursor greater distances.
Selection
Selection and navigation are closely linked. Selection is done from the keyboard by pressing the Shift key while moving the cursor by means of the navigation commands. All navigation commands can be combined with Shift, thereby enabling selection, for example: If you want to select the whole table (the area A1:G9) when the cursor is located in G9, you press Ctrl+ Shift +Home, and presto, the table is selected. www.excelkurs.com Page 7
2009
Alternatively we may use the command Ctrl A to select the whole table (when the cursor is located inside the table). The first use of Ctrl A will select the table; the second use of Ctrl A will select the whole sheet. You may practice this by using other keyboard commands for selecting parts of a table!
Smart summing-up
We all know Excel is clever when it comes to summing up numbers, but do you know that Excel can sum up this way: In this case we want the table summed both horizontally and vertically, in other words we are going to make 13 formulas. We can create a formula in B9 and auto-fill it horizontally, and we can create a formula in G2 and auto-fill it vertically. But, we can do it even quicker: Select the range (or table) to be summed up, including the blank column to the right of the table G2:G8, and the blank row below the table - B2:G9
One click on the Auto Sum Button will create the 13 formulas instantly. You tell Excel whether you want to sum up the table horizontally, vertically or both ways by selecting the empty column to the right or the empty row below the table.
Copying formulas
Instead of creating formulas one by one, we can use the Auto-fill function to copy a formula from one cell to several other cells. The vertical copying (or Auto fill) is normally accomplished even quicker by double clicking the Auto Fill handle instead of grabbing ahold of it and dragging it. This is particularly www.excelkurs.com Page 8
2009
useful when you want to auto fill a formula vertically over a large number of rows. If you have tried this you will know that you will often end up several hundred rows down on the sheet, and then you have to reverse your motion, and so on. This wont happen if you double click as Excel will only auto fill as far down as there are corresponding cells to the left of the formula. Notice that the auto-fill stops if there is a breach in the series that is an empty cell in the closest column on the left.
If you drag left or right in the indicated location, the selected columns will get the same width.
www.excelkurs.com
Page 9
2009
Example: We have a reference number like this: 30-8. If we enter this into a cell, it will be transformed into 30. August. As we understand, the entry is interpreted as a date, and the cell is formatted accordingly. That gives us two challenges: How do we prevent this from happening, and how do we get rid of the date formatting of this cell? Prevention: We can either: Pre-format the cell as Text, or Type an apostrophe () before we enter whatever needs entering. The apostrophe () will format the content to Text.
Removal: We can apply another format, or remove both content and format (Home Editing Clear Clear All)
www.excelkurs.com
Page 10
2009
List functions
A list in Excel-is a collection of data organized in such a way that various tools and functions in Excel can be applied to it. Characteristics of a list: Each column has a heading The heading is formatted different from the content(for example bold) Preferably nothing above the list itself No blank rows or columns No information located to the right (or the left) of the list
www.excelkurs.com
Page 11
2009
Sorting
Located in Home Editing Sort & Filter (Also in Data - Sort & Filter Sort) We select the Sorting Key by placing the cursor in the column we wish to sort by, and then clicking the sorting buttons to sort the list in ascending or descending order.
Note! Do not select the whole column we want to sort by! If we do, we risk sorting only the selected column, thereby messing up our list totally. Excel through version 2003 can sort by up to three simultaneous keys, while Excel 2007 has an unlimited number of keys available. If you want to sort by another system than alphabetically or numerically top to bottom or bottom to top, you can click the Order dropdown menu on the sort setup dialog. This option gives you access to all your Custom Lists, and they can be used as sorting keys.
Subtotals
Located in Data Outline Subtotals Practice file: Pivot og delsammendrag.xls We have a very quick and easy way of extracting information from a large list by using the tool Subtotals. Point your pointer to Data Subtotals to use this tool. In this case, we have asked for a sum of www.excelkurs.com Page 12
2009
the columns Antall, Brutto pris and Netto pris at every change of Selger. The Subtotal-function groups the salespersons and totals their sales :
By clicking the numbers (1, 2, 3) in the top left corner we can change the detailing of the numbers. If we want to remove the subtotals we point to Tools Subtotals and select Remove all. Note! Before applying subtotals to a list, we have to sort it by the key we want to subtotal by, in this case Selger. The Subtotals-tool works fine with limited amounts of data, but tends to be very slow executing larger volumes. Some testing on a data list with 85 000 records shows that generating subtotals, and changing subtotal options can take 2 . 3 minutes. Generating and changing a pivot table on the same data takes no measurable time at all.
Filter
Located in Home Editing Sort & Filter (and in Data Sort & Filter Filter) Earlier versions of Excel used the term Auto filter. Functionality of the filter has been vastly improved in the 2007 version, and the term is now simply filtering. Filtering makes it very easy to filter out records we have no interest in seeing in order to see those that are of interest to us. The procedure is as follows: Place your cursor inside the list, point to Home Editing Sort & Filter, and filtering buttons will be placed at the top of each column.
www.excelkurs.com
Page 13
2009
Using the Auto filter is simple and intuitive. , we just deselect or select the records we want to leave visible. We can combine as many conditions as we need to in order to secure the desired result.
Advanced filter
Located in Data Sort & filter - Advanced In earlier versions of Excel we had to resort to the Advanced filter function ever so often. As described above, the functionality of the Auto filter has been expanded so much that we only very rarely should have to use the advanced filter. Hence, I will limit my coverage of the advanced filter to saying that it should be used when or if the desired results are not achieved by the Auto filter.
2009
The Remove Duplicates Tool is easy and logical to use, the only obvious caveat being the fact that Excel deletes the duplicates without asking your consent. If you feel you have to inspect the duplicates before they are deleted, you have to resort to the old way of doing this, which is described in the following paragraph. If we start with the practice file, we first need to sort the records based on Customer ID. This will place possible duplicates adjacent to one another. We then use the IF-function to compare each and every Customer ID with the next one. The formula looks like this: =IF(B2=B3;Duplicate;). Use Auto fill to extend this formula to all cells in column A. As we have asked the IF-function to type the word Duplicates next to a record that is equal to the one above, we can quite easily see where the duplicates are located. However, if we have a large list with thousands of records, we would probably want to relocate all duplicates to the top of the list. This entails a little more than just sorting the list. First of all we need to end the dependency of the comment Duplicates on the content of the adjacent column. This we do by converting the formula into value, or put in another way, into the result of the formula. 1. Select the cells that are to be converted 2. Copy the selection (leave the selection) 3. Point to Home Clipboard Paste Paste values The copied area is now pasted on top of the area we originally selected and copied, and the formulas are converted into whatever they were showing at the time. Now we have only the text Duplicates next to the duplicates, and we can sort the list (descending) without any problems. This will place all duplicates on the top of the list, where they can be easily inspected, deleted or edited. We can also envisage that the criteria for a duplicate is that both the Customer ID and the namecolumns have equal contents. The procedure is in principle the same, but the formula is a bit more complicated: =IF(B2&C2=B3&C3;"Duplicate";""). By using this system we can ask Excel to check any columns for duplicates, either individually or in any combination. The practice file shows this case in detail.
www.excelkurs.com
Page 15
2009
The MIN, MAX and AVERAGE functions are basic and obvious both in their use and their functionality, so we will not cover them here. We will concentrate on functions that require more input than just a selection in the worksheet.
The IF-function
Practice file: HVIS-funksjon This function enables Excel to make a choice for us, in its most basic form between two alternatives, based on the outcome of a logical test. =IF(TEST;TRUE;FALSE) A test (or a claim) has two possible outcomes, either it is TRUE or it is FALSE. This example shows how we can use the IFfunction to assign the correct membership fee to the members of the homeowners association based on a test of their age:
If the age is greater than (or equal to) 67, the fee is 75, is it is less than 67, the fee is 150. This is the formula: =IF(C9>=$C$6;$C$5;$C$4) After entering the formula into cell C9, we use the auto-fill handle to copy it into the other cells in the range (C10:C20), making sure we use the absolute reference-designation correctly. Another example of the use of the IF-function can be found is the file HVIS-lnn.xls. Here we test for the value of the sales of each person in order to decide if they should have a bonus, and what it should amount to. Please refer to the file for all details on this example.
www.excelkurs.com
Page 16
2009
The IF-function can be used to select between up to 7 alternatives when we use the technique of nesting the functions, that is to say putting them inside each other. An example of such use is located in the file Nested IF-functions. ,
The SUMIF-function
Practice file: Ordrer.xls The SUMIF-function sums up a given column based on a matching criteria in a column to the left. What is the total value for the field Belp for the customer Alfreds Futterkiste? We can easily answer that question using this function.
Range is the range where the criteria is located Criteria is in this case the name of the customer. To make a more flexible solution we prefer to refer to a cell where we enter the criteria instead of typing the criteria into the dialog. Sum_range is the range that we wish to sum up. COUNTIF counts the number of occurrences of a text or value, for example how many occurrences are there of the customer Alfreds Futterkiste in column A.
www.excelkurs.com
Page 17
2009
Validation
Located in Data Data Tools Data Validation By using the validation tool, we can decide what can be entered into a cell. The practice file depicts a case of reporting financial info. The user can enter information into the input cells. These are the only cells where information can be entered, and we have decided what kind of information can be entered. In the cells C3 and C6 only predetermined alternatives from a drop-down list can be entered, while in cells B7 and B8 only numbers within a given range can be entered. To set the limitations on what may be entered, point to Data Data Tools Data Validation. Here we can see that initially we can enter anything into a cell. Then we can set the validation parameters: Cell C3: Here we are to register one out of five departments, and to make this job as easy as possible for the user, we select: Allow: List Source: here we can type the alternatives, separated with a semicolon, and when we tick In-cell dropdown, the alternatives will appear on a dropdown-list. We can also refer to a list that we have typed somewhere else in the same worksheet. There is a way around having to place the list in the same worksheet, and that is naming the location of the list and referring to that in the Source-field. www.excelkurs.com Page 18
2009
We can choose to visit the tabs Input Message and Error Alert and type an instruction and an error message. Cell C6: Here we select Allow list and enter the names of the reporters, in the same way we entered the alternative departments for the first cell, or by referring to a range within the worksheet that contains the list of months. Cell C9: This is the cell where we are to enter the revenue figures. To keep the user from entering a digit too few or too many, we can set a lower limit of 30 000 000 and an upper limit of 40 000 000, based on empirical data, as shown on the right:
Cells C11, C12: Expenses can be validated in a similar way. The other cells contain formulas that retrieve their information from the input cells, so we do not place any validation criteria on these.
Protection
Step one - unlock cells is located in Home Font Open group - Protection Step two protect sheet is located in Review Changes Protect Sheet Now that we have decided what can be entered into the cells, it is time to make sure nobody tampers with the validation or with the formulas, for that matter. Before we do that, two things must be clear: On the menu Home Font Open group Protection: Any cell is by default set to Locked. This setting has no effect until we protect the sheet. Any cell with the formatting set to Locked will be unavailable after Protect Sheet is activated. Consequently, we have to deselect the Locked setting before we activate Protect Sheet.
www.excelkurs.com
Page 19
2009
The final step is to activate the Protect Sheet function in Review Changes Protect Sheet We have now achieved two things: We have decided which cells are available for data entry, and We have decided what can be entered into the same cells.
Output validation
We first and foremost use data validation to control and limit what is entered into a cell. But, we can also use validation on an output cell, which is a cell containing a formula. The scenario is then somewhat different. It would be unthinkable to deny the display of whatever values appear in such a cell, so we use this function to accentuate values that are outside what we deem an acceptable range. The screenshots are from the file Validering og beskyttelse.xls. You can also find examples in the file Analyseeksempel.xls. To show which cells put out values outside an acceptable range, we set the validation as described earlier. To circle unacceptable values we point to Data Data Tools Data Validation Circle invalid data. This will make Excel circle unacceptable values with a red circle. We click the next button to remove the circles.
Conditional formatting
Practice file: Analyseeksempel.xls Located in Home Styles Conditional formatting The tool Conditional formatting can be used to focus on values that are remarkable in a positive or negative way. This function has been refined and developed substantially in Excel 2007. The illustration shows one example on how it can be used, showing data bars in each cell in the selected range:
www.excelkurs.com
Page 20
2009
Pivot table
Practice file: Pivot og delsammendrag.xls Located in Insert Table PivotTable. Earlier, we have looked at the use of the tools Subtotals, Auto filter, and Advanced filter to retrieve information from large lists. The Pivot Table is a tool that does many of the same things, usually even more elegantly than the other tools. Once more we can open this file and ask ourselves the inevitable question: How are our salespersons actually doing? The procedure is as follows: Place your cursor inside the list Point to Insert Table PivotTable and check the proposed selections in the dialog. When you are satisfied they are as desired, click ok and the template for the Pivot Table is created. To move our data into the Pivot Table, tick the appropriate boxes in front of the column headings shown on the right. Let us start with a simple request; we want to know what each salesperson has sold of the various products, and the value series is the net price. To answer this question, we tick off Selger, Produkt and Netto pris. This produces a table like this: We are not too happy about this configuration, so we wish to rearrange the table to make a cross table with the salespersons as row labels and the product as column labels.
www.excelkurs.com
Page 21
2009
To do this, we grab ahold of the field Produkt in the area Row Labels on the right and move it to the area Column Labels. This renders a table like this:
This is better, now we have a great outline of what the various sales persons have sold of the different products.
We can experiment my moving the fields around in the table, thus rendering other displays.
The Pivot table is an extremely powerful tool, maybe the most powerful analysis tool in Excel. Data can be analyzed in innumerable ways using this tool. The example described here is definitely the short version of the saga of the Pivot Table, and should be considered as a quick introduction to the subject.
2009
we count columns from left to right (within the matrix), and the index 2 will give us the first name of the employee. This file also contains an example on the use of the function .HLOOKUP. Note! Two important considerations: You should make sure you enter the parameter FALSE into the field Range_lookup, like this: If we do not do that, Excel will return the closest value to the one we asked for, and this may have unforeseeable consequences. If we enter 120 instead of 102 as we intended, Excel will return the name of the number closest to 120, which is 110. This is somebody entirely different from the person we were looking for!
The sorting sequence doesnt mayyrt when we use VLOOKUP with the FALSE logic. There are, however, times when we want to use VLOOKUP with the TRUE logic, meaning we want the closest match with the lookup value. In such a case, the lookup column has to be sorted in ascending order. or the lookup will return wrong results. Have a look at the file Nested IF and VLOOKUP.xls for an example of this use of VLOOKUP.
www.excelkurs.com
Page 23
2009
PMT
Practice file Mlsking.xls This function calculates the payment per term for an annuity based loan, and as such is useful to everybody involved in financial calculations. When the function is set up properly, the parameters can be changed, and we can see the result on the payment directly.
Note! The interest rate that is referred to from cell B2 must be divided by the number of terms per year in cell B3. Also, the total number of payments (B5) must be the result of a formula. If it is typed into the cell, it wont update when parameters are changed, and the payment will not be correct.
SUMPRODUCT
Practice file Pivot og delsammendrag.xls The SUMPRODUCT function seems to lead a somewhat anonymous life. The function is a true powerfunction, and it can do the most amazing things. From that perspective, it may not be very sensational to be able to multiply two arrays with each other and give us the sum. What is more impressive, is its ability to do these things while taking multiple conditions into consideration. Somewhere else in this compendium I have mentioned the new-for2007 function called SUMIFS, which is also able to do that trick. A more general way of saying this is that SUMPRODUCT can do some of the tricks of an Array Formula without www.excelkurs.com Page 24
2009
behaving like and being an array formula. In the example above, we can use SUMPRODUCT to extract information about the sales of one or more products for a given salesperson, or for multiple salespersons, for that matter.
Array formulas
Practice file: Array formulas.xls
Now, if our sole interest is the grand total, we could go straight to that by using an array formula. An array formula must be entered in a particular way, by hitting Control + Shift + Enter If you close it the normal way, with only Enter, you will sometimes get an error message, and sometimes the wrong answer, so make sure you remember this!
2009
TRUE * TRUE = TRUE TRUE * FALSE = FALSE 1*1=1 1 * 0 = 0, or 1*1*1*1*0=0 So, all it takes is one FALSE/ZERO in a calculation, to give the calculation the outcome of FALSE or 0. What this means in practice, is that only records where all conditions come out with TRUE or 1, will be retrieved. This is a screenshot of the file Pivot og Delsammendrag.xls:
We can extract Herbert Schulz sale of bukser with the following array formula: =SUM((A2:A12=Herbert Schulz)*(B2:B12=Bukser)*(H2:H12)). Remember to close with Control + Shift + Enter!
When should I use array formulas, and when should I use Pivot Tables? Different people have different preferences, but the general answer would be this: Use pivot tables for quick analysis of static data. Nothing beats pivot tables for speed and ease! Use formulas when you design a model that will live over some time, and where the data changes, or grows. The (array) formulas will make sure you always have updated and correct calculations, no manual action is required.
www.excelkurs.com
Page 26
2009
D-functions
Practice file D-funksjoner 2.xls
www.excelkurs.com
Page 27
2009
Goal Seek
Practice file Mlsking.xls Located in Data Data Tools What-if-analysis Goal Seek This is a simple and easy-to-use tool that calculates backwards by simulating alternate input arguments in a function much quicker than we are able to do this. Example: We are buying a new house. We have calculated that we can manage 8000 per month in payments. The interest rate is 6%, and the bank says the maximum number of years for repayment is 15. How much money can we borrow? We have looked at the function PMT earlier. We might use this and simply type in amounts until we were close to our 8 000 per month. This would take some time, and we would never be able to get an accurate amount. However, if we use Goal Seek, we can get the exact amount immediately: Locate Tools Goal Seek on the menu, and enter parameters as shown: Set cell B9 to value 8000 by changing cell B3 - and we have the answer immediately.
Solver
Practice file: Solver.xls Located in Data - Analysis - Solver Goal Seek is ok for its intended use, but in many cases we have problems with multiple variables. These variables have to be optimized simultaneously and against each other, and that is not possible with Goal Seek. We have to use a much more advanced tool, the Solver. Example:
www.excelkurs.com
Page 28
2009
We have a budget for next year for our company. This is no common budget where we calculate values outside the budget-model and enter the values into the model. This is a live budget application where we want to optimize the use of our advertising money. The idea is that spending money for advertising will increase our sales, up to a point. When a certain level of spending has been reached, more spending will not increase sales sufficiently to leave is a profit. Thus, beyond this point, we will lose money by spending even more for advertising. The real-world challenge is of course to know the formula that relates Sammenheng mellom reklameinnsats og overskudd these two The profit culminates 120000 parameters. here? Graphically we can render it like this: 100000
80000 60000 40000 20000 0 Alt 1 Alt 2 Alt 3 Alt 4 Alt 5 Alt 6 Alt 7 Alt 8
Advertising spending Reklameinnsats: Profits Overskudd
Note! If you cant find the Solver-tool at the described location, it has not yet been installed. In that case you have to run the installation routine. Click the Office button and point to Excel options Add ins, and select Excel Add-ins. Select the Solver Add-in in the lower part of the window and click Go. Excel 2007 should normally not ask for the installation disk. We will now maximize the profit (F14) by letting Solver redistribute advertising spending between the quarters, but at this stage we do not accept an increase in the total advertising spending. To illustrate how we do this, we set a limitation to total advertising spending (F13): in the constraints group, click add www.excelkurs.com Page 29
2009
and type/select: F13<=40000. We also have to tell Solver that advertising expenditure in any given quarter cannot be less that 0, that is to say that negative numbers are not accepted. The constraint looks like this: $B$13:$E$13>0. With these criteria the profit is maximized to around 109 000. If we run the simulation without setting any limitations on advertising spending, the profit will go up to 145 000, and advertising spending will be more than 160 000. This is the point where the graph for profits starts pointing down. The Solver is a very powerful tool, b it in order to use it meaningfully, we need models that describe reality in a realistic way. To design such models is often the problem.
Scenarios
Practice file: Budsjettscenario.xls Located in Data Data Tools What-if-analysis Scenario Manager The term scenario is a familiar term to everybody working with accounting and finance. We often have three scenarios, one worst case, one best case, and one middle-of-the-road. Technically scenarios can be handled in many different ways, even with adjacent columns in the budget. Excel has a built-in tool that enables storing several different values in one cell, and retrieving these values based on selecting the different scenarios.
Example: Here we have a small and simple budget consisting of one cell for income and one for expenses. These two cells have three alternative values connected to three scenarios, and we will now enter and store these values in their respective cells. We start by entering the numbers for the scenario Worst Case. In order to keep track of the different scenarios, it is a good idea to enter the name of the scenario in a cell here B7. The next step is to select the cells in the scenario, B3:B4 and B7. Go to the scenarios tool (see location above) and click Add in the dialog. Type the name of the scenario and click ok until we have closed the dialog. Next, we deal with the other two scenarios the same way. After entering the three scenarios, we can point to the different scenarios the Scenario Manager, and change scenario for our budget by selecting the appropriate scenario and clicking show.
www.excelkurs.com
Page 30
2009
Consolidation
Practice files: Konsolidering Oslo.xls, konsolidering Bergen.xls, konsolidering Trondheim.xls Located in Data Data Tools - Consolidate These three files all show sales figures for our branches in these three different cities. Now, we want to total the numbers. There is however, a problem with that; the three worksheets we need to total are not equal. We have different brands of cars, and they are placed haphazardly in relation to each other. We could build formulas to sum up all this, but with a large number of cells, we would be lucky to get everything right, and we would spend quite some time accomplishing this. This is where the tool Consolidation shines. It is able to sum up sheets based on referring to column and row headings, not the usual cell references! Example: First, open all three files, and then open another blank workbook. Point to the consolidate tool to start the dialog. Leave the cursor in the field Reference, browse to the first open workbook (Oslo), select A3:D10, and click Add in the dialog. Next, browse to Bergen and Trondheim do the same procedure. Make sure you select correctly, you need to include the column and row headings. The dialog should look like the illustration above: Note! We have ticked off all three tick boxes for labels and for links to the source data! The new workbook is now showing the totals, and we have accomplished this very quickly!
Clicking the plus-signs in the left margin will display the specification behind every consolidated number. As the months do not appear in their correct www.excelkurs.com Page 31
2009
sequence, we should sort the columns. Start by selecting the columns C through G. Go to Data Sort and Filter Sort. Clikc the Options button and select Sort left to right: Then you go to Order, select Custom List and locate the months in the list: This will re-arrange the columns, and the months will be placed in their correct sequence.
2009
We wish to import a table from a page at the website of Norwegian Statistical Office. The address is http://www.ssb.no/fobhusinnt/tab-2003-12-18-01.html Some of us may have tried to import by just selecting and copying data from a web page and pasting into a worksheet. In most cases this is highly unsuccessful. The correct way of doing this is to use the Import Wizard in Excel. The Import Wizard can be engaged two ways, either from Excel, as described below, or simply by right-clicking (Export to Microsoft Excel) the web page we wish to import. Start by opening the web page referred to above. Here you may right-click the page, or do the following: Select the URL (the web address) and copy it to the clipboard (Ctrl C) Go back to Excel and point to Data Get External Data From Web A mini-browser appears, and we now paste the address that we just copied into the address field at the top, replacing the start page address that is there. Hit Enter (or click Go)
After a few seconds the page will open, and we get these yellow selection handles that enable us to import only the stuff we want form the page. We just select the table(-s) we want to import by clicking the yellow arrow. Next, click Import, then select destination cell, and presto, everything is nicely imported into the worksheet. The numbers are correctly formatted, and we can now proceed in our analysis of the numbers. In most cases you can accomplish this result by simply right-clicking in the web table and select Export to Microsoft Excel. The caveat with the right-click method is that you are not given a choice to select parts of the web page, you will in most cases get the whole web page imported into Excel. Note! This works only with Internet Explorer tests with other browsers have all been unsuccessful.
www.excelkurs.com
Page 33
2009
www.excelkurs.com
Page 34
2009
Text to columns
Using the built-in tool Text to columns is normally the easiest way to accomplish the splitting. This tool is located in Data Data Tools Text to Columns. Example: In the worksheet Tekst til kolonner we want to split the municipality number and the name and place these in separate cells: Procedure: Insert two new columns between cols A and B Select the cells you want to split(A9:A26) Point to Data Data Tools - Text to Columns Here we have the choice to split on a character or on fixed width, and as the municipality number has four digits, we can use both ways. As some of the municipalities have hyphenated names we get the best and easiest results by going for fixed width. Next, we see the dividing line between number and name. If we select B9 as destination cell, we wont overwrite any of the present information in the worksheet. To avoid losing the leading zero in the number, select the column and format it as Text:
Thats it, we have split number and name and placed them in separate cells.
www.excelkurs.com
Page 35
2009
If we had not formatted the number as text, we would have lost the leading zero. If we are presented with material where this has happened, we can use the following procedure to rectify the situation:
Procedure: Select the cells in question Point to Format- Cells Custom Type four zeros into the field Type.
A few words on text vs. numbers in the postal (zip) code. As long as the numbers are to continue living their lives in Excel, we can keep the described formatting. However, if we want to work on these numbers in certain ways, notably merging the numbers into a Word document, we will run into trouble. The merging process will once more remove the leading zero. The solution to this is to do as described above, format the number as text during the import procedure.
The numbers will now be stored as text, and the leading zeros will survive any abuse we might subject them to. But, they will be text, and we cant use them for any kinds of calculations.
www.excelkurs.com
Page 36
2009
www.excelkurs.com
Page 37
2009
Lets say we are looking at the Resultat cell and we are wondering where this number actually comes from. Place your cursor on the cell, click the Trace precedents button, and arrows will tell you where the input to this formula. Click once more, and you will see where the contents of those cells stem form, and so on. If you get a dotted arrow with an icon depicting a worksheet at the end, point to the arrow, and double click. You will now get a dialog showing the origin, and you can follow it by selecting the reference and clicking ok. Using this technique, we can follow the trail all the way to the end. or rather, the start of the model.
www.excelkurs.com
Page 38
2009
IFERROR simplifies handling of error messages substantially. As we have seen earlier in this publication we have had to use a combination of IF and ISERROR to make Excel (2003 and earlier versions) type a free text in case of an error message. This can now be accomplished directly by using this function.
AVERAGEIF corresponds to SUMIF and COUNTIF, and it calculates the average from a series of values while taking into account a given criteria. The following formula gives the average of values that are greater than 100 in the selected range:
Practice file:
Averageif.xlsx
=AVERAGEIF(A2:A5;>100;B2:B5) AVERAGEIFS works with more than one criteria. SUMIFS In earlier versions of Excel we have the function SUMIF (and COUNTIF). These are great for their intended use, but what if we need to sum while testing for multiple criteria? This can be done in these versions, but it is a rather daunting task. This has become very simple in Excel 2007.
Practice file:
Improved graphics
I guess we all expect things to look a little nicer in the new version of an application. This hope is fulfilled in the newest Excel. Among other things, the graphics engine that makes graphs, has made great leaps, for unrivalled graphics rendering.
www.excelkurs.com
Page 39
2009
Conditional formatting We have discussed conditional formatting at length before. This functionality has been dramatically improved for 2007. This is an example on how we can use CF to render numbers more understandable in relation to each other.
Salg 127 935 202 651 238 567 127 101 192 267 150 504 225 494 162 690 221 378 Salg 127 935 202 651 238 567 127 101 192 267 150 504 225 494 162 690 221 378 Salg 127 935 202 651 238 567 127 101 192 267 150 504 225 494 162 690 221 378 Salg 127 935 202 651 238 567 127 101 192 267 150 504 225 494 162 690 221 378
Graphics rendering The improvements mostly consist of a nicer look to graphics. A graph in Excel 2007 may look like this:
300 000 Salg Kostnader 200 000
250 000
150 000
100 000
50 000
1 2 3 4 5 6 7 8 9 10
www.excelkurs.com
Page 40
2009
Or, we may go to war with a partly transparent data point in a graph. All in all, the possibilities for Salg spending hours and days improving the looks of your graphs have taken a great leap forwards.
150 504
192 267
www.excelkurs.com
Page 41
2009
Internet resources
What you cant find on the internet, is hardly worth finding. You can feel certain that whatever problems you are faced with have been encountered by a few thousand, or even a few million users somewhere else in the world. The search engines are great for retrieving this information, so just go ahead and type in keywords. Example: Lets say I dont know how to split cells. I will therefore try a Google search like this: Excel split cells In less than a second I am presented with more than 194 000 references to this subject.
Websites
There are several websites dedicated to Excel. Just pay them a visit and do a search if you have a problem. You can find lot of great tips here. http://www.j-walk.com/ss/ - this is John Walkenbachs website, the author of The Excel Bible http://www.cpearson.com/excel.htm http://www.mrexcel.com And, my own website is also updated regularly with new Excel tips: http://www.excelkurs.com
Practice files
This compendium is accompanied by a package of practice files. You can download this package from www.excelkurs.com . The link yopu should look for is called Zippede vingsfiler.
Copyright
All rights to this compendium, other compendiums published on www.excelkurs.com , practice files, and other downloadable material, belong to Tore Sfting. You are granted a license to use this material for developing your Excel skills, solving Excel-related problems and related activities. Use of this material for training third parties is prohibited.
www.excelkurs.com
Page 42
2009
Index
A
Advanced filter, 14 Array formulas, 25 Auto filter, 13 AVERAGE, 16
G
Goal Seek, 28
O
Output validation, 20
H
help, 42 hiding error messages, 37 HLOOKUP, 22
P
Pivot table, 21 PMT, 24 protection, 18 Protection, 18, 19
C
cell formatting, 9 column headings, 11 column width, 9 Conditional Array Formulas, 25 Conditional formatting, 20, 37, 40 Consolidation, 31 Copying formulas, 8 COUNTIF, 17, 39
I
IF, 16, 21 IF-function, 16 Importing, 32, 34 Internet, 32 Internet resources, 42 ISERROR, 37
R
Remove duplicates, 14 Repeat heading, 11 Right mouse button, 10 row height, 9
S K
keyboard shortcuts, 41 Scenarios, 30 Selection, 7 Solver, 28 Sorting, 12 Subtotals, 12 SUMIF, 16, 17 summing-up, 8 SUMPRODUCT, 24
D
Database, 27 DAVERAGE, 27 D-functions, 27 DMAX, 27 DMIN, 27 DSUM, 27 duplicates, 14, 15
L
list, 11, 14, 15, 18 List functions, 11 live data, 34
M
MAX, 16 MID, 35 MIN, 16
T
Text to columns, 35 Tracing, 38
E
error messages, 37
F
Filter, 13 formatting, 20 functions, 16
N
Navigation, 7
V
Validation, 18 VLOOKUP, 22
www.excelkurs.com
Page 43