ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 Introduction to Excel for Science Students The focus on this handout is on the use of the Excel spreadsheet (part of the Microsoft Office XP suite). When you have worked through this handout you can expect to have acquired general familiarity but more specifically to be competent in the use of Excel up to a level where you can use the standard features; entering and formatting data, but also some more advanced features, such as basic formulas and creating charts. Excel is an extremely powerful package and there is plenty more to be learned about it than can be covered here. If you wish to take it further then the ACOM optional component on Data Handling and Presentation will be an excellent place to start. There are two versions of this handout, which cover similar ground (and indeed have a good deal of material in common), but which differ from each other in having a slightly different style and academic focus. This version, entitled Introduction to Excel for Science Students, is intended primarily for students in the sciences and accordingly takes its worked examples from scientific data. Students in non-technical disciplines who would prefer an approach that confines its examples to historical and social data should consult instead the alternative version, Introduction to Excel for Humanities Students. 1 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 What is a Spreadsheet? One of the things for which computers are particularly useful is the handling of repetitive calculations, because unlike us they don’t get bored, irritated, distracted or careless. For example, if as a teacher you have 300 students on a course with three pieces of coursework and you want to calculate the average mark for each student, it would take an afternoon to do by hand and you’d almost be able to guarantee some errors. Furthermore, if the data changed in any way, you would have to recalculate everything relating to the changed data. To do these sorts of job on a computer you would be well advised to use a spreadsheet, which is a tool that makes such tasks very easy to do, won’t make any mistakes, and will take seconds (at least once you’ve entered the data). In a simple spreadsheet, data are arranged in a grid with each “cell” (i.e. box of the grid) containing a single numerical value. Calculations can be performed on whole rows or columns of numbers. If you change the value of any of the numbers in a spreadsheet, all calculations referring to that number will be redone taking into account the change. This means that once set up, spreadsheets can be used to model the effects of changes on whole systems. Although spreadsheets started out as tools in accountancy (as a means of doing the many boring sums that are required to keep a balance sheet) they can now do much more than add up. In this handout, you will be taken through using a spreadsheet to make calculations, produce charts, and carry out some simple statistical functions, and will also learn how to incorporate charts into a Word document. Getting Started: Setting up Excel The Spreadsheet package that you will be using is called Excel. It is a very powerful package, and we will only scratch the surface of its capabilities in this handout. Microsoft Excel can be run from the Windows desktop. To start Excel, either double click on the desktop icon, or select Excel from the Start button on the task bar, and go to Programs | MS Office XP When Excel has loaded, you should see the main Excel window, showing an empty spreadsheet (appearing as a grid of labelled rows and columns, with the title “Book1” across the top). On the right hand side of the window is the “New Workbook” Task Pane which allows you to create a new blank workbook or to open an existing workbook. After you have done so, the Task Pane will automatically close (or you can close it yourself by clicking on the “X” button on the top right of the window). The task pane can be opened again from the View menu. The screen should look like the picture on the following page. If for any reason it doesn’t, call up the View menu (by clicking on the word “View”) and check that there is a tick next to the “Formula Bar” item on this menu – if there isn’t, click on that item. Also in the View menu, click on “Toolbars...” and check that the “Standard” and “Formatting” have been selected. 2 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 The Excel window upon opening Workbooks, Worksheets and Cells Excel organises data into “workbooks”, each of which can contain a number of (usually related) spreadsheets – Excel calls each spreadsheet within a workbook a “worksheet”. This means that you can have many spreadsheets easily accessible within the program at the same time, making it very easy to copy data from one to another, or to have one spreadsheet linked to the results of calculations carried out on another spreadsheet. When you save an Excel workbook, all spreadsheets contained within that workbook are saved into the same file. To begin with, however, we shall use only the first “sheet” of the workbook. When you start up Excel, even though you haven’t asked for a new file, a blank workbook (usually called “Book1”) is opened, with the first blank worksheet of that workbook (“Sheet1”) displayed. This looks like an empty grid, with letters across the top and numbers down the left-hand side. A spreadsheet consists essentially of just that, a grid of cells, which are organised into columns and rows. Each column is referred to by a letter, and each row by a number. Each individual cell can be identified by specifying its column and row – e.g. the top left-hand cell is A1 (always specify the column first). Along the bottom of the screen are a number of labelled “tabs”, like those on index cards, which say “Sheet1”, “Sheet2” etc. These select the separate worksheets available in the open workbook. To move from one worksheet to another, you simply click on the tab referring to the one you want. For the moment, you don’t actually need an empty workbook, because you are going to cover the basics of Excel using a spreadsheet that’s already been created for you. Closing a file in Excel is exactly the same as in most other Windows applications – use the left mouse button to select the File menu, and then move the mouse down to the “Close” item on that menu (as pictured here) before releasing the button. When you’ve done this the Excel window will become a lot simpler as there is no longer an active file. You will now need to download the example file that is needed to complete the exercises in this handout. It is available from the Teaching Materials page on the ACOM web site. Select the line appropriate to this handout– “Hawdat.xls” – and the file you require will be copied to your home directory. Once you have downloaded the file, there should be no need to do so again. When you have the relevant file in your home directory, go again to the File menu in Excel and select “Open...”. A dialogue box will appear, very much like the Open File dialogue box in Word. Assuming that your home directory is selected, names of the files that you have copied over should appear somewhere in the list box on the left of the Open File window, and amongst these should be “hawdat.xls ”. If you can’t see this you probably need to change drives in order that the files on your “home” disk area are shown: to change drives, click on the ò symbol to the right of where it says “Drives” and scroll up or down in the resulting menu until you can see, and click on, “m:\”. When “hawdat.xls” does appear in the Open File list box, highlight it and then click on “OK” – the Excel window should then look like the picture on the next page (though in order to illustrate how an active cell appears, this picture shows the spreadsheet after the mouse has been clicked on the cell B2). 3 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 The Excel Window on loading HAWDAT.XLS When using an Excel spreadsheet, most of the time there will be one “active” (and “selected”) cell. Such a cell has a darker border than all the other cells, and also has a small dark square in the bottom right-hand corner. Also, the “address” of the active cell (e.g. “B2”) is shown at the left of the Formula Bar, which runs across the top of the Excel window just under the toolbars, and the contents of the active cell are shown in the remainder of the Formula Bar. When adding or altering data, only the active cell can be changed, but you can make any cell you want become the active cell using either the mouse or the keyboard. Using the mouse, simply click once on the cell that you want to make active. Using the keyboard, move to the cell you want to make active by using the arrow keys. There is a shortcut for making the top left cell (A1) active – simply press the Home key whilst holding down the CTRL key. Later in the handout you will see how it is possible to select more than one cell at a time, in order for example to format them all in one operation or to move their contents around together – these groups of selected cells will usually form a rectangular array. However in such cases the Formula Bar will still show the address and contents of a single “active” cell amongst the group (usually the top left cell in the array), and if you now type some data in it will be only that one active cell which is affected. So although a cell being “active” and being “selected” come to much the same thing whenever you’re dealing with a single cell, there is a distinction between them when a number of cells are involved – many cells can be selected together, but only one can be active. Layout and Text Formatting The spreadsheet HAWDAT.XLS contains data on the Hawaiian-Emperor chain of volcanoes.1 As you can see, it is not particularly well organised, and moreover contains a few typing errors, notably in the heading. 1 This spreadsheet is based upon results quoted in Table 1 of the paper “Volcanic periodicity along the Hawaiian-Emperor chain” by Herbert R. Shaw, E. Dale Jackson and Keith E. Barger, American Journal of Science 280a (1980), pp. 667-708. 4 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 Changing Column Widths The first thing to do to this spreadsheet is to change the width of the columns so that all of the text becomes readable. To do this, position the mouse pointer between two column selectors at the top of the spreadsheet (for example, A and B). Then move it around a little if necessary until it becomes a line with a horizontal arrow coming out of each side. When it is a two-headed arrow, hold down the left mouse button and (slowly) move the mouse to the right. The column on the left should become larger, and all of the columns to the right of it should move along to make space without themselves changing in size. Try this out in the spreadsheet HAWDAT.XLS, arranging the column widths so that all the writing in column A and the headings in columns B, C, and D are fully visible. You will notice that when the cell(s) to the right of a cell containing text are empty, Excel allows the text to run over into the next cell so you don’t need to adjust the column width to see its entire contents. An example of this is the heading in Row 1 of the spreadsheet HAWDAT.XLS. Changing Font Size To make the spreadsheet HAWDAT.XLS easier and clearer to use, we can highlight the heading by changing the font size and by making it bold or italic, just as in Word documents. To do this in Excel, move the mouse over the cell in which you wish to change the formatting. The mouse pointer should become a chunky cross. Click once on the cell – this should select it, so that it appears with a thicker border. When you have done this, click on the Bold button, which should be on one of the toolbars across the top of the screen (if it isn’t, please refer to the section on setting up Excel on page 2). As with Word, there are three buttons for text formatting: Bold, Italic and Underline. Also like Word, there is a font type box and a font size box. These character formatting options all apply to the selected cell(s). If you wish to select more than one cell, you can hold down the left mouse button (but only when the mouse pointer is a chunky cross) and drag the pointer over the cells you wish to select. This has the effect of selecting a rectangular array of cells, which then appear with a thick border around the entire selection. In this way, you can select groups of cells for text formatting (and as you will find out later, calculations). You can also select whole rows and columns by clicking on the row or column selector buttons (e.g. the “A”, “B”, “C”, “1”, “2” and “3” buttons – being able to do this is particularly useful if you wish, say, to centre an entire column, or to italicise or embolden an entire row). Inserting Rows and Columns Excel has a very useful shortcut menu, the contents of which change depending upon what part of a spreadsheet you are in and what cells are selected at the time you call the menu up. To see this shortcut menu, select a cell (or cells) and click on the right mouse button. This menu is particularly useful when you want to insert rows or columns. To insert a column, click once on the selector of the column where you would like the new blank column to be inserted – this will highlight that column. Then either click once on the right mouse button and select “Insert” from the resulting menu, or click on the Insert menu (from the standard Menu Bar along the top of the screen) and select Column from there. A similar technique applies for inserting rows: highlight the row where you want the new blank row to go (by clicking once on its row selector) and then use either the right mouse button menu or the Insert menu to insert the new row. Notice that when you insert a new blank column or row the existing column or row at that position is not overwritten, but instead moves along or down to make space for the insertion. 5 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 In the spreadsheet HAWDAT.XLS, insert another row now beneath the rows containing the headings (i.e. beneath row 4), by clicking with the left mouse button on row selector 5, then with the right mouse button to call up the shortcut menu, and finally select “Insert” from that menu. Aligning Text and Numbers In Excel, numbers are initially automatically aligned at the right of a cell and text at the left. 2 However, you will not necessarily want to stick with these default alignments. To practise changing the alignment of some cells, select the entire array of numbers in the spreadsheet HAWDAT.XLS by dragging the mouse (when the pointer is a chunky cross) from cell B6 to cell D24. Next, click on the Centre button on the formatting toolbar. The contents of the selected cells will now become centred. There is one alignment button on the Excel toolbars which you will not recognise from Word - this button (pictured on the right here) allows you to centre an item of text across a range of cells (treating them for this purpose as though they were a single cell), and can be particularly useful for headings. To use this function, highlight the relevant range of cells (which should include the text you wish to centre) and then click on the button. Adding Borders One further way in which the presentation of an Excel spreadsheet can be improved is by adding borders around specific cells. Borders can function like underlining, helping to identify titles and table headings, or they can be used to clarify the structure of a spreadsheet by enclosing related information in boxes. You can put a border all round a cell, or along any selected sides of it. As with text formatting, the application of borders applies only to the cell or cells which are currently selected. To add a border to a cell or array of cells, select the cell or cells by dragging the mouse, and then click on the ò button next to the Borders button on the Formatting Toolbar. A selection of border types will appear – as you can see from the picture, you can have single line borders, borders consisting of two lines, thick borders, thin borders, and a variety of other choices. And you can have borders at the right- or left-hand side of the active cells as well as the top and bottom. To test out using borders in a spreadsheet, highlight the table headings in row 4 of the spreadsheet HAWDAT.XLS, and give them a thin border along the bottom of the cells. Next highlight the row headings in column A of the spreadsheet, and give these cells a thin border along their right edge. Entering and Editing Data To enter new data into an Excel spreadsheet, click on the (presumably empty) cell in which you wish to enter it, and then simply type the data into that cell. You will see the characters you type appear simultaneously in two places in the Excel window – within the actual cell that you’ve selected, and on the Formula Bar across the top of the open spreadsheet. The data you enter is not finalised until you do one of three things: press Enter, press one of the arrow keys, or click on the green tick that appears on the Formula Bar while you type. Until you do one of these things, pressing Escape or clicking on the red cross on the Formula Bar will make whatever you have typed disappear. It may seem overly complicated to have three different ways to do the same thing, but each of the methods is useful in different situations. If you are typing in a whole column of numbers, using the downarrow or the Enter key means that you don’t have to move from the keyboard to the mouse in order to finalise the cell contents. However, if you are moving around entering numbers in different parts of the spreadsheet, using the mouse to finalise the entries can be useful as you are likely to be using it anyway to move from one part of the spreadsheet to 2 This gives a handy way of knowing when you have typed in a number incorrectly: if you have accidentally included a non-numeric character in a number, it will come up aligned to the left, not the right. 6 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 another. Try entering new text now, by typing the word “Average” into cell A25 of the spreadsheet HAWDAT.XLS. (Cell A25 should be the first empty cell below the volcano names.) Sometimes you will want to replace data that is already entered. This is very easy with Excel, because whatever you type into a cell just replaces whatever was there previously, so you can simply treat any cell with old data in it the same way as if it were empty cell. In the spreadsheet HAWDAT.XLS, one of the cells contains incorrect data: it reads “1000” when it should read “103” (this was originally cell B7, but should now be cell B8). Click on this cell and type “103”, then either press Enter, press one of the arrow keys or click with the mouse on the green tick. You will then see that the contents of the cell have changed accordingly. To edit data already entered within a cell but without totally replacing the contents of the cell (e.g. if the cell contains text, or a complicated formula which you want to modify without typing it all out again), first make the cell you wish to edit the active cell, when you will notice that its contents appear on the Formula Bar at the top of the screen. Then move the mouse over the Formula Bar until the pointer of the mouse becomes an I-bar (a pointer shaped like a capital “I”, as in the picture here). Click once on the text on the Formula Bar, and a cursor will appear where you have clicked. You can now edit this text in the usual manner making use of the arrow keys, Backspace, Delete and so on. When you have finished, either press Enter or click on the green tick to finalise your changes. Try this out now, by correcting the typing error (“Enporer”) in the heading of HAWDAT.XLS. Click on cell A1, then click on the Formula Bar in the region of the “Enp” and correct this to “Emp”. 7 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 Performing Calculations During this section we will use Excel to perform calculations. To include calculations in your Excel workbook you can create your own formulas. Formulas are mostly used to perform calculations such as additions, subtractions, multiplication and divide. More complex functions can be carried out but these are not covered here. To perform a calculation in Excel, you have to enter a Formula. Formulae in Excel start with an equals sign: this is how Excel knows that a formula is being entered and not just text. If for some reason you want a cell to contain text that starts with an equals sign, you should type an apostrophe before the equals so Excel will know it’s not a formula. Sometimes Excel will convert numeric data that you have entered into dates’ e.g. 10-12 will be converted into 10th Dec, to stop this happening, prefix the data with an apostrophe to let Excel know that you are entering numeric data. Excel can carry out all sorts of calculations – some of the commonest kinds are shown in the table below. Entering a formula is similar to entering data or text: you first select (and thus make “active”) the cell where you want the result of the formula to appear, and then you type “=” followed by the calculation that you want the spreadsheet to perform. Simple Arithmetical Functions in Excel Function Example Description * =A2*A5 Multiplication / =A2/A5 Division + =A2 + A5 Addition - =A2 – A5 Subtraction Some commonly used Functions in Excel 8 Function Example Description SUM =SUM(A1:A14) Calculates the total in a range of cells AVERAGE =AVERAGE(A4:B5) COUNT =COUNT(A4:A19) Counts the number of cells that hold numerical values in a group of cells. MAX =MAX(A4:A10) Gives the maximum value in a range of cells MIN =MIN(A4:A10) Enters the minimum value in a range of cells Calculates the average (or “mean”) of a group of cells ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 To practise using simple formulae in Excel, we can fill in row 25 of HAWDAT.XLS (which we previously labelled as the “Average” row) Click on cell B25, and type in “=AVERAGE(B6:B24)”. This formula instructs Excel to calculate the average of cells B6 to B24. You will notice that when you finalise the contents of cell B25 (by pressing Enter, pressing one of the arrow keys or clicking on the green tick) the formula you have typed in still appears on the Formula Bar but the result of the formula now appears in the cell. You’ll see from the table above that the formula for the sum of a range of cells has a similar syntax to the formula for an average, but because summing rows and columns is one of the most common types of calculation, if you do want to enter a “SUM” formula then you can make use of a convenient shortcut that Excel provides by means of the “AutoSum” button in the Toolbar. If you make a particular cell active and then click on this button, the active cell will be made to contain a “SUM” formula as though you were in the process of editing it, thus giving you the opportunity to change the relevant range (or even, as we will see, the function itself) before finalising the formula. In the present case we don’t actually want to insert a “SUM”, but as an illustration, click on the cell C25 and then on the AutoSum button – when you do this, the text “=SUM(C6:C24)“ will appear in the cell C25 with the range “C6:C24” highlighted. This means Excel has worked out that C6:C24 is probably the range that you want, because it is a contiguous range of cells directly adjacent to the active cell C25 and all containing straightforward numeric data (not formulae). But you can if you wish change the formula – do this now by clicking on the word “SUM”, then editing it using Delete and/or Backspace so that instead the formula reads “=AVERAGE(C6:C24)”. Finally, press Enter (or click on the green tick on the formula bar) to make Excel accept the finished formula. 3 AutoFill Excel has a feature called “AutoFill”, which takes formulae or other data that you have typed in and “spreads” them to adjacent cells, continuing any simple sequence that it finds there (e.g. if you have one cell containing “Tuesday”, and “spread” this onto adjacent cells downwards or to the right, then AutoFill will automatically continue the series of days forwards through “Wednesday” etc; while if you spread it upwards or to the left, AutoFill will continue the sequence backwards through “Monday” etc). AutoFill can have strange effects if you are not sure what sequence Excel might see in your data, but it can be very helpful either for applying a similar formula (e.g. a sum) to several adjacent columns, or for filling in quickly a large number of “label” cells (e.g. to label a table of data). To use AutoFill, you should first select the cell or cells containing the formula or data that you want to “spread”, and then move the mouse pointer over the small square in the corner of the selection. The mouse pointer should become a thin cross, like the one shown on the right here. When this happens, hold down the left mouse button and drag the cross over the cells that you wish to fill with the spread formula or data. When you release the mouse button, the cells you have just covered will be filled accordingly. Try this now using the spreadsheet HAWDAT.XLS. Make cell C25 (the one in which you most recently entered a formula) active, and move the mouse pointer over the bottom right corner of this cell until it becomes a thin cross. Hold down the mouse button and drag the cross over D25 to cell E25 (as you do so, a thick grey border should enclose the cells over which you move). On releasing the left mouse button, you will notice that D25 and E25 now contain formulae which are of exactly the same type as the formula in 3 We saw earlier that when a number or formula has been typed straightforwardly into the active cell, clicking elsewhere has much the same effect as pressing Enter (i.e. it accepts the number or formula in its current state). But in this AutoSum context – where part of the formula is highlighted – a mouse click within another cell (or a mouse drag over other cells) will be treated as putting a reference to that cell (or cells) within the formula. A similar point applies if, for example, you type the unfinished formula “=AVERAGE(“ and then drag the mouse over a range of cells: try it to see what happens. This can be a very convenient technique for inserting cell references into formulae, but it can also be confusing if you don’t know what to expect! 9 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 C25 but with different column references – hence D25 calculates the average of cells D6 to D24, while E25 calculates the average of cells E6 to E24 (since the cells in column E are empty, however, this gives an error message). Make sure you’re quite clear about what’s going on here, by clicking once on each of the cells and chec king what the Formula Bar contains. As you can see, the AutoFill is a great labour-saver when you want to calculate totals or averages (or whatever) of a number of columns of data – having typed the formula into one column, you can “spread” it along the row to the others. And the AutoFill can work in just the same way when it comes to spreading formulae down columns – you’ll see this in action shortly. To see other effects of AutoFill, select a cell in an empty column of HAWDAT.XLS and type the number “1”. Then use AutoFill to spread this to a number of other cells lower down in the same column – you will see that the AutoFill simply copies the “1” that you have typed in into all the cells over which you drag the thin cross. Now change the second “1” in this column to a “2”. Select the cells containing the first “1” and the “2” (by clicking and dragging when the mouse is a chunky cross) and then use AutoFill to replace the rest of the column of “1”s. You will see that something different happens – very useful if you want to number all the rows of your spreadsheet! AutoFill is not the only function available when the mouse pointer is a thin cross, for if you drag the cross in the opposite direction (up or left instead of down or right) you can use it instead to make cells blank. Select an array of cells (those you just filled with “1”, “2” etc for instance), and move the mouse pointer over the bottom right corner of the array until it becomes a thin cross. Then hold down the left mouse button, but instead of dragging the mouse outside the selected cells, drag it inside the selection – you’ll notice that the cells inside the selection are highlighted in grey as you pass them. When you release the left mouse button, all of these grey cells will be made empty. 4 One great advantage of using a spreadsheet to set up tables such as the one that we’ve just completed in HAWDAT.XLS is that if some of the data happen to change, Excel will automatically recalculate all of the formulae that refer to those data. 5 To watch this happen, simply change the number in just one of the cells in HAWDAT.XLS, and when you press Enter (or click in another cell etc), the totals which correspond to that cell will also change. However we don’t really want to change any of the numbers in HAWDAT.XLS permanently, so this gives an opportunity to illustrate also the useful Undo button (pictured on the right). If you click on the Undo button, the last change made will disappear. This idea should be familiar, because Excel’s Undo button operates just like Word’s, except that, unfortunately, Excel’s Undo facility can undo only the very last action – it doesn’t remember any further back than that. Click on Undo now, and whatever number you previously changed will be changed back. Now, to reinforce the skills that you have just learned, fill column E of the spreadsheet with calculations of the percentage uncertainty in the age of each volcano – this means that you must work out what proportion the “Error” in column D is as a percentage of the “Age” in column C (e.g. in the case of Kanau Seamount in row 21, the uncertainty or “Error” is 3 million years, which is 7.5% of the estimated “Age” of 40 million years). If you’re at all unsure of doing this correctly, you might as well take advantage of the clue in the previous sentence, by clicking on the cell E21 and filling in there the necessary calculation for the volcano Kanau Seamount (then at least you know what the answer should be!). Remember, since it’s a formula you’re entering, that it should start with an equals sign, and make use of the cell references “C21” and “D21” rather than the values that those cells contain. If you need to look up the symbols for multiplication and division, refer to the table on page 8. Having put the correct formula in cell E21, now use 4 Two other ways of making a selection of cells blank are (a) to select the cells in question and press the Delete key; or (b) to select them, click on the right mouse button, and choose “Clear Contents” from the shortcut menu. 5 Excel will, not surprisingly, complain if you enter a formula and then change the nature of cells on which the formula is supposed to operate (e.g. if you enter the formula “=F3+F4” into cell F5, and then edit cell F3 to contain text instead of a number, you’ll get the error message “#VALUE!” in the cell F5). If you get such error messages and don’t understand what to do about them, consult Appendix 2 at the end of this booklet. 10 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 the AutoFill to “spread” it first down to cell E24, and then up to cell E6 (observing, as you do these operations, the effect on the “AVERAGE” formula that you earlier put into cell E25). When you have spread the formula to cell E6, however, you will probably find that it gives there the error message “#DIV/0!” – quite rightly, because cell C6 contains zero, and hence the calculation of D6 as a percentage of C6 involves an illegal division by zero (in cases like this, it’s a good idea to keep the spreadsheet tidy by replacing the formula that generates the error message with an asterisk “*”).6 The “#DIV/0!” error message is quite self-explanatory, but others can be less obvious (e.g. “#####” would just indicate that the column is too narrow to display that cell’s contents). If you come across any that you don’t understand, refer to Appendix 1 at the end of this handout, entitled “Troubleshooting for Formulae”. Numeric Formats Having filled in column E, you will probably find that the numbers displayed there are rather untidy, with the precise Kanau Seamount value appearing as just “7.5”, but all of the “non-round” values being shown to an accuracy of as many decimal places as will fit into the width of the column (up to a maximum of 10 significant figures). It would obviously be far neater to display all of the figures to the same level of accuracy, such as one decimal place. To change the numerical format of some group of cells, first as usual select them with the mouse (so that a border appears around them), then choose “Cells...” from the Format menu, click on the “Number” tab within the dialogue box that appears, and click on the word “Number” in the “Category” list down the left-hand side. Essentially, the point of this dialogue box is to enable you to specify a “Category” and a “Format Code” for any numerical values that appear in the selected cells. By selecting an appropriate option from the “Category” list these values can be made to appear as financial amounts, dates, times, percentages, fractions and so on, but by choosing the “Number” option you have indicated that you want them to be treated as numbers in ordinary decimal notation (for scientific notation, you would choose the “Scientific” option). Then, given that they are to be displayed as ordinary decimal numbers, you can select an appropriate precise format for them by means of the “Decimal Places” list in the middle. Excel provides a versatile system of numeric format coding, and if you want anything out of the ordinary you would be well advised to consult the section on “Number Format Codes” in the Excel Help system (which can be called up either from the Excel Help menu or from the “Help” button in the dialogue box pictured here). Returning now to column E, first type a relevant heading into cells E3 and E4 (e.g. “Error” and “%age” respectively), then select the entire column by clicking on the column selector button at the top – note that the numeric reformatting you’re about to perform won’t have any detrimental effect on the heading you’ve just inserted, because that consists of text rather than numbers. Having selected the column, follow the procedure outlined above to change the numeric format of the column so that it displays numbers to an accuracy of precisely one decimal place, and then align the numbers in the column to the right, so that the decimal points all line up neatly. Then when the column is right-aligned you can still ensure that the numbers don’t appear squashed against the right-hand edge. When you’ve got the numbers looking right, do a final check that any non-numeric entries in the column (e.g. the headings and the asterisk or error message in cell E6) are also neatly arranged – you’ll probably find that these look best centred. 6 When you enter the percentage formula into E21, and then when you spread it down to E24, you will notice that the “AVERAGE” formula in E25 ceases to show the error message “#DIV/0!”, and instead presents, as it should, the average of whatever values appear above it in the E column. But the same error message reappears for a different reason once the percentage formula has been spread to E6, because then E25 is attempting to calculate an average with the illegal error value in E6, and this is not allowed. Replacing the formula in E6 with an asterisk (or any other text) has the advantage of omitting it from the average calculation and thus avoiding the E25 error message. But if you do this and then look at the values in column E, you’ll see that their average – now visible in E25 – is pretty misleading and unrepresentative (owing to the overwhelming domination of the Mauna Kea value over everything else), so it’s probably sensible just to delete the “AVERAGE” formula from E25 in any case. Taking averages doesn’t always make sense! 11 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 We’ve so far been treating the entries in column E as straightforward numbers, but you should be able to find an even better way of formatting them if you bear in mind that they are, in fact, percentages. As an exercise, see if you can do so now by following the same procedure as above except that you select the “Percentage” rather than the “Number” option from the “Category” list in the Format Cells dialogue box. As you do this, pay close attention to what results from your reformatting – you should notice that when you tell Excel to display a number as a percentage, it multiplies the number by 100 for you, so for example “0.5” appears as “50%”. Hence to display column E as a percentage, you will need to change the formulae in cells E6:E24 (or E7:E24). See if you can do all this for yourself. You have now learned how to lay out and format an Excel spreadsheet and the cells within it, to enter new data, edit old data, carry out reasonably complex calculations and fill in rows and columns with formulae or data sequences. Now we shall move on to producing graphs and charts. But first, save the spreadsheet HAWDAT.XLS in its new form, so that if anything goes wrong in what follows you won’t lose the work that you’ve done so far. 12 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 Using Excel to Produce a Scatter Chart Using the data in HAWDAT.XLS you are now going to create a scatter chart. The first step in creating a good chart of any sort is to select the right data – and this is just as true of making a chart in Excel as it is of making a chart using graph paper and coloured pencils. One rule of thumb which is useful when thinking about what data to include is that it is usually a bad idea to include within the same chart both a variety of totals and also the data that make up those totals. Also, if you want to give a breakdown of a single total, use a pie chart. As you will have discovered in the previous section, some of the data in the spreadsheet HAWDAT.XLS are not as reliable as they could be. Where the uncertainty in age is more than 100% of that age, for example, it is obviously reasonable to discard the data as unreliable. Bearing in mind this point and the point made in the previous paragraph, the area you want to select when it comes to making a scatter chart out of the data in HAWDAT.XLS is the range of cells B8 to C24. 7 Use the mouse to select this range of cells now. Having selected them, click once on the ChartWizard button. “Wizards” in Excel and other Microsoft programs are routines which consist of a series of dialogue boxes which automate various operations in a simple step-by-step manner. Following the series of boxes in the case of ChartWizard takes you through the selection of data, the selection of chart type, and whether or not you want data labels or titles. The end product is a chart of whatever type you want with your chosen information and labelling. When you click on the ChartWizard button the first window to appear (the “Step 1” window) asks you which general chart type you would like. There is a wide range of chart types available in Excel, as you can see, and it is important to pick an appropriate chart for the data that you are representing. However in Excel it is very easy to change from one chart type to another, so you needn’t be too anxious about this – if you’re not sure which chart type to select, just try out a few before deciding. For the data in HAWDAT.XLS a scatter chart (called by Excel an “XY (Scatter)” chart) is probably the most suitable. So click now on the type of chart you want (the “XY (Scatter)” type has been selected in the picture on the right here). Excel will display the variety of sub-types available in the Chart Sub-Type box. Here there are a number of different options, but which ones are offered will obviously depend on the general chart type that you have selected. Having decided on a scatter chart, you can for example choose: whether to have a scatter that compares values, or with data points connected by smooth lines. It is worth experimenting with different styles of chart to see which one looks the best for the data you are using. Do this by selecting your provisional choice (in the picture on the right here, option 1 has been chosen), click the Press and Hold to View Sample button and a larger sample of the chart will be displayed. When you have selected the chart click on the “Next >” button to continue to the second step of the ChartWizard, which as we shall see also includes a preview of the finished chart, so if you don’t like the way the preview looks you can then go back (using the relevant dialogue box’s “< Back” button) and try out a different general chart type or different chart style. You can carry on flicking between dialogue boxes 2, 3 and 4 in this way, experimenting as much as you like before making your final decision. 7 If you were creating a different type of chart it could be useful to include the column (or row) headings, as with certain types (e.g. bar charts, histograms and pie charts) Excel can include this information automatically. The easiest way to find out how to produce different chart types is to experiment (but remember to save the file and to use the Undo button if you don’t want to lose what you’ve previously done!). 13 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 At this point the selection of cells you made will develop a flashing border and Step 2 of the Chart Wizard, as well as showing a preview of the finished chart will also ask if the selected cells are indeed those that you wish to chart. It will say something like “Range: =$B$8:$C$24”. (There is a reason for the $ signs, to do with absolute cell addressing, but for now we can safely ignore them.) Check that this is the range you want to chart (i.e. it includes all the reasonable data but not the averages, headings or unreliable data), then move on. If this window does not display the correct range of cells, you can type in changes by deleting the range in the window and entering another (in the simpler format of two cell references separated by a colon, e.g. “=B8:C24”). Below the Data Range the dialogue box provides a pair of buttons which determine how the data values are grouped, which can be according to either the Rows or the Columns of the spreadsheet. In our volcano example you will need to select “Columns” if Excel has not already done so, because in this case the data are unambiguously arranged in columns rather than rows (i.e. each column contains a single “homogeneous” kind of data, whereas each row does not), so that selecting “Rows” would give a very strange effect (try clicking on the “Rows” button now to see what happens, but be sure to change back to “Columns” before moving on). With other kinds of data, however, particularly those in which rows and columns provide alternative ways of categorising a single population of objects, it may be the case that either method of grouping is possible and you may wish to look at both before deciding which is the more appropriate. When you are happy with the preview, press the “Next”> button to go on to Step 3. The options in the Step 3 dialogue box gives you further choices regarding the labelling of the chart (obviously this will depend on the chart type you first selected). The choices of whether to add a chart title and/or axis titles (here, as you can see, both chart and axis titles have been added), or whether to remove/include a legend. It is obviously a good idea to give the chart as a whole a title, if only as a means of reminding yourself what you have charted. But whether in addition the chart would benefit from axis titles and/or a legend is more a matter of discretion. Bear in mind that too much text can clutter the overall effect, and that the main purpose of a chart is precisely to put across data in such a way that overall characteristics which could otherwise be obscured become obvious. A central requirement of this is clarity, and if a chart is either overly or insufficiently labelled this objective will not be achieved. Note: Excel calls the horizontal (x) axis the “Category” axis and the vertical (y) axis the “value” axis. The following is a brief description of the remaining spin boxes: • Axes tabs would enable you to suppress the display of any of the axes, but you would not generally want to do this. • Gridlines are lines drawn across the chart for visual reference, you can choose which gridlines to display on your chart by selecting or clearing the Major/Minor gridline check boxes. • Legend allow you to show or clear the legend. If you choose to show the legend you can use the placement buttons to indicate where it should appear. • Data Labels you can select a variety of options from the Data Label group box. E.g. you can choose “Show Value” to have the value of data points appear on the chart bars associated with them. • Data Table tab allows you to show the table of the data from which the chart was drawn along with the chart. When you’re quite happy with the sample chart in Step 3 of the ChartWizard, click on “Next”>. 14 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 Step 4 of the Chart Wizard will ask for the Chart Location. You cam select whether to have your chart appear in a new worksheet or alongside the data it is charting. To insert the chart in a new worksheet click on “As new sheet” and then click on Finish. Or to have the chart appear alongside the data you are charting select “As object in”. Then click on Finish. You will be returned to your spreadsheet, which will now contain the chart you have designed. If this is too large to fit on the screen or too small to see all the detail, you can re-size it very easily. You will notice that when the chart first appears the midpoints of its sides, and its corners, are marked with eight small black squares, indicating that the chart is currently the “active” part of the spreadsheet (so the squares will disappear if you click on a spreadsheet cell, but will reappear when you again select the chart by clicking on it). 8 If you move the mouse pointer over one of these squares, the pointer becomes a double-headed arrow, because the square is actually a “resizing handle”, which can be dragged and dropped to change the size of the rectangular “chart box” – dragging a side handle will change either the width or the height of the chart, while dragging a corner handle (diagonally, as indicated by the arrow direction) will change the chart’s size whilst maintaining the proportion between its width and height (the picture above shows the bottom right corner handle just about to be dragged). Resizing can be particularly important if you find that headings or category labels are omitted from your chart – if this happens, it will be because there’s insufficient room for them, so if you stretch the chart appropriately they should reappear. When you are content that the chart you have produced is the right size, save the file HAWDAT.XLS. Creating and Organising a New Spreadsheet We’ll now work quickly through an example to which a pie chart is appropriate, but which also brings out some other aspects of the creation and design of a new spreadsheet. The data we are going to present in our spreadsheet come from the following paragraph in the article on "Earth" in the Microsoft Encarta 97 Encyclopedia.9 “The rocks of the lithosphere have an average density of 2.7 and are almost entirely made up of 11 elements, which together account for about 99.5 percent of its mass. The most abundant is oxygen (about 46.60 percent of the total), followed by silicon (about 27.72 percent), aluminium (8.13 percent), iron (5.0 percent), calcium (3.63 percent), sodium (2.83 percent), potassium (2.59 percent), magnesium (2.09 percent) and titanium, hydrogen, and phosphorus (totaling less than 1 percent). In addition, 11 other elements are present in trace amounts of 0.1 to 0.02 percent. These elements, in order of abundance, are carbon, manganese, sulfur, barium, chlorine, chromium, fluorine, zirconium, nickel, strontium, and vanadium. The elements are present in the lithosphere almost entirely in the form of compounds rather than in their free state. These compounds exist almost entirely in the crystalline state, so they are, by definition, minerals .” The data in this paragraph can be displayed to best advantage in a pie chart, but before we can attempt to do so, the figures first need to be unravelled a little. Open a new Excel workbook (by selecting “New...” from the File menu) and make a table listing the elements and their abundance as best you can. You will notice that titanium, hydrogen and phosphorus have to be treated together as a group, as do the eleven trace 8 Since the chart is selected when it is first created by the ChartWizard, if you decide you don’t want it after all you can erase it immediately by just pressing the Delete key. The chart can similarly be removed at any other time too, by selecting it and then pressing the Delete key. 9 Article contributed by Earl Cook. Copyright © 1993-1996 Microsoft Corporation. All rights reserved. 15 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 elements, since in each case the percentage abundance is given for the group as a whole and not for the individual elements. Moreover the abundance of each of these groups is given only implicitly, and hence has to be calculated on the assumption that all the percentages should add up to 100% (with all but the trace elements accounting for 99.5%). You could do these calculations yourself, or insert a relevant formula, but either way it would be sensible to include at the bottom of the relevant column a “Total” (using the AutoSum), just to make sure that you’ve got them right. When you’ve done all this, your spreadsheet might look something like the picture on the right. In passing, it’s worth noting some things that have been done to tidy this spreadsheet, using the check box and some of the buttons that are available through the “Alignment” tab of the Format Cells dialogue box • The text in cell A11 has been “wordwrapped” by checking the “Wrap Text” box in the “Alignment” tab of the Format Cells dialogue box. • The text in row 11 has been given a “Centre” vertical alignment using the appropriate button in the “Alignment” tab. • The list of trace elements has been stretched out over the cells A15 to C15 by both checking the “Wrap Text” box, and clicking the relevant button to give a horizontal alignment of “Centre across selection”. Notice also that the numbers in column B have been neatly aligned to the right of the column, being displayed to two decimal places and with three trailing spaces (using the Number Format Code “0.00 ”). Our table of elements indeed now looks quite presentable, but unfortunately it’s not ideally suited for producing a pie chart because the labels which it contains (“oxygen”, “silicon” etc) are far too long – in any pie chart, space is likely to be at a premium, and this will be especially true of one in which some of the “slices” are extremely thin. So while preserving the full-length labels in column A, it would be advisable to supplement them with some much shorter labels that can do duty within the chart, and for this purpose the obvious choices are the standard chemical symbols (“O”, “Si”, “Al”, “Fe” etc) together with straightforward abbreviations for the two groups of elements (e.g. “Ti/H/P” and “Trace” respectively). However in order for chart headings or labels to be recognised as such by ChartWizard, they have to be adjacent (on the left or top) to the data that are being charted. This means that if you want to create a chart, then unless you’ve already put everything in exactly the right place you may have to move around the numbers and formulae that you have entered – in the present case, for example, the numeric data need to be moved from column B to column C, and the abbreviated labels inserted in column B. Cut, Paste, Drag and Drop Editing There are several ways to move things around in Excel, of which the most obvious is to use the Clipboard (much as you would in Word). To do this first select the cell(s) containing the data that you want to move, then choose “Cut” from the Edit menu (or click on the scissors icon in the Toolbar), 10 then select the cell(s) to which you want the data moved, and finally choose “Paste” from the Edit menu (or click on the Paste icon in the Toolbar). 11 Note that with two exceptions, when you Cut (or Copy) data from any array of cells, you should ensure that the selected destination cell array is of the same dimensions, otherwise Excel will complain (you can’t, for example, copy a 2x3 array of data into an 3x2 array). The two exceptions are: (a) when the “source” array is just a single cell, you can Paste its contents simultaneously into as many cells as you want; and (b) when the “destination” array is just a single cell, the Paste command interprets this as 10 Cut and Paste are also both available on the right mouse button shortcut menu. 11 You may notice that Cut and Paste in Excel do not act in quite the same way as they do in Word – most obviously, when you perform a Cut the selected cells do not immediately become blank, but instead merely acquire a flashing dotted border. It is not until you select the destination cells and then Paste (or you can even just press Enter) that the data are moved, being deleted from the source cells and placed into the destination cells at the same time. Moreover once this has happened those data do not remain in the Clipboard – unlike Word, the Clipboard in Excel operates only on a transitory basis. 16 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 meaning that pasting should occur to the appropriately sized array of which that single cell is the top-left corner. (As always, the best way to familiarise yourself with this behaviour is to experiment for yourself.) Also note that if the destination cells contain data before you do the moving, those data will be overwritten when it takes place (so make sure that you’re not overwriting information that you wanted to keep). Another, and often quicker, way of moving text and data around in Excel is by “drag and drop editing”. With this method, you first select the cells whose data you wish to move, and place the mouse pointer on the thick border around the edge of the selection – as you do so, the pointer should turn into an arrow. Then hold down the left mouse button, and drag the border (a grey copy of which will move with the mouse pointer) to the place where you want the data to be moved. When you have this grey border where you want it, release the left mouse button and the selected data will move accordingly. As with cutting and pasting, moving can overwrite the existing contents of the destination cells if they are not empty, but before overwriting Excel will helpfully display a prompt saying “Replace contents of Destination Cells?”, which gives you an opportunity either to change your mind (i.e. to “Cancel” the data movement) or else to confirm that it is “OK” for the existing contents of the cells to be overwritten. Now use these techniques to rearrange the data in your new spreadsheet so that you have room to enter the new abbreviated labels into column B. Then insert these labels (consulting the picture on page 18 if you’re unsure of the appropriate chemical symbols). Then, save your new workbook (using the File menu or the Toolbar Save icon), calling it “ELEMENTS.XLS”. Creating a Pie Chart using ChartWizard Creating a pie chart in ChartWizard is very similar to creating a scatter chart. The main thing you have to consider is the selection of which data fields to include, and as usual, you should not include totals or averages, but might well wish to include labels.12 In the present case (assuming that the previous column B values have been moved horizontally into column C, and that column B now contains abbreviated labels), the appropriate range will be “B3:C12”, so select the range now and then call the ChartWizard by clicking on its icon. In the Step 1 dialogue box, select Pie from the Chart type. From the variety of subtypes available in the Chart Sub-Type box, select a sub-type (in the picture on the right pie with a 3D visual effect has been selected). The difference between these is purely in their dimensional appearance; again it is worth experimenting with different styles of chart to see which one looks the best for the data you are using. Just as we saw when producing the scatter chart, you should be prepared to experiment by moving back and forth between the ChartWizard dialogue boxes, trying out a variety of options until you find a chart that looks good, and that presents the information clearly and efficiently. Again as we saw in the case of the scatter chart, the Step 2 dialogue box provides a preview of the chart, and gives an opportunity for checking both that the data are being taken correctly from rows or columns and the range of cells you are charting is correct. The Step 3 dialogue box allows you to add a title (desirable) and/or a legend (essential unless the slices are labelled), and any Data Labels such as values or percentages after which you can click on the “Finish” button to Enter to Excel and view your completed chart. 12 Excel produces its pie charts by adding up all of the data values selected and working out what proportion of the total each value represents. Hence it is essential that each data value in the “population” should be counted once and once only, and if you include totals in your selection you won’t end up with an accurate pie chart. Note, by the way, that although in this case the selected data values add up to exactly 100, there is no requirement that they do so. 17 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 Making Alterations to a Finished Chart You can make alterations to the layout and style of a chart in Excel even when you have finished the ChartWiz ard. Indeed some such alterations are completely automatic, for just as the results of formulae in Excel change when the data to which they refer are adjusted, so the contents of a chart will also change when adjustments are made to the underlying data – you can try this out now by adjusting any of the values used in the construction of the pie chart (but bear in mind as you do so that the Excel Undo “remembers” only one operation). Other alterations can be selected using buttons and menus, using the small “floating” toolbar which appears whenever a chart is selected (i.e. when the mouse is clicked on the chart, and it acquires those small black squares around the edge). 13 In the picture of the toolbar below, the button representing a legend is depressed: this means that the active chart features a legend. If you click on this button the legend should disappear, and likewise if you click on it when it’s not depressed, a legend will (re)appear. The Chart Toolbar displays nine buttons allowing you to modify different parts of the chart. And finally the Chart Type button allows you to change the type of chart: if you click on the ò button a menu of the available basic chart types will appear and you can simply select from them (but be warned – you may not be able to Enter to your original chart if you experiment with all this, so it’s a good idea to save your worksheet first, or else to use Undo after each and every “experiment”). As well as the options offered by this toolbar, you can edit any part of a chart manually – to do so, first double-click on some item in the chart, when it should acquire a thick diagonally striped border (as in the picture below). Then the options available will depend on the nature of the chart, and you may just have to experiment to get a feel for the possibilities (don’t worry about this, because most hand-editing operations are equally easy to undo by hand). Here we’ll begin by focusing on a few of the main editing facilities relevant to pie charts, because this type of chart that you are most likely to need to edit (to avoid cluttered labels etc, as mentioned earlier). Clicking on the chart title will enable you to edit it as text in the usual manner. Clicking on the pie itself highlights it (i.e. surrounds it with black square “handles”), and you can then drag the mouse to make all the slices of the pie come apart. If you want to emphasise one particular pie slice, you can click on just that slice so that it alone becomes highlighted, and then drag that slice away from the rest of the pie. Selecting a small slice can be fiddly – here the best thing to use is not the mouse but the left (or the right) arrow key on the keyboard, which will cycle through the chart’s components in turn and thus eventually select the slice you want. You can also select any chart label in this way, and then use the mouse to move or delete it if necessary (as is being done in the picture here). 14 Double-clicking on any part of a chart brings up a new window with options to change the colours, fill patterns or other features depending on the chart type and where exactly you clicked. It’s worth experimenting with this: for example you can change all the label types by double-clicking on the chart body, and this gives a way of labelling the slices of a pie chart with absolute values rather than percentages (an option surprisingly absent from the ChartWizard menus). If you adjust the 13 If this toolbar doesn’t appear, then select “Toolbars...” from the View menu and check the “Chart” box. 14 In this case, the best combination of clarity and informativeness is probably to delete the “Ti/H/P” and “Trace” labels, and to rely on the legend to convey that information. 18 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 colours and fill patterns then bear in mind that you will probably be printing in black and white – but you can see roughly how the screen colours will appear in grey on the printed page by clicking on the Toolbar’s Print Preview button. In fact Excel sometimes “chooses” colours that will not print particularly well, and changing your colours can be the only way to get a clear printed output of your chart (unless you are able to print in colour). Inserting a line of best fit The alterations covered so far in this section are broadly cosmetic – they have little effect on the information conveyed by the chart. But there are other possible modifications that are more significant, and an example of this is the insertion of a “Trendline” or line of best fit. Trendlines can only be inserted into certain types of chart (and obviously not into a pie chart), so move now to the HAWDAT worksheet in your open spreadsheet, which should contain the scatter chart you produced earlier. To insert a trendline into a scatter chart, you first have to select the data. To do this, highlight the chart (by double clicking on the chart area) and then click in the region of one of the data points. All of the data points should become highlighted (as in the illustration here). When you have the data points in the HAWDAT worksheet highlighted, select “Trendline” from the Chart menu.15 A dialogue box will appear asking you what sort of trendline you would like to have on your chart. Select the appropriate type, and then click on “OK” if that is all you want to include. However, clicking on the “Options” index tab before clicking on “OK” offers you the useful possibility of including the equation of the trendline in your chart. Simply check the “Display Equation on Chart” box (and then click on “OK”). As with other elements of charts, you can edit the appearance of the trendline once you have inserted it by double-clicking on it while the chart is active, and then changing any of the attributes that are available from the resulting dialogue box. Excel also provides two functions for calculating the position of a line of best fit without actually drawing it. The first of these is “SLOPE”. In the usual way, any formula containing this function should start with “=SLOPE(”, after which you can click and drag the mouse to select the range of cells that constitute the y-values of your graph (i.e. those up the vertical axis – the Age data in cells C8 to C24 in the case of HAWDAT) – you will see that the formula bar reflects the cells you select. Next type a comma, and then select in the same way the cells which make up the x-values of the graph (i.e. those along the horizontal axis – in the case of HAWDAT the Distance data in cells B8 to B24). Finally, type a closing bracket and press Enter. The formula bar should read “=SLOPE(C8:C24,B8:B24)”,16 and the cell in which you typed the formula should now show the result of the calculation. The INTERCEPT command for working out the y-coordinate of the point where the best fit line cuts the y-axis has an identical structure to the SLOPE command, so here the relevant formula for the HAWDAT data is “=INTERCEPT(C8:C24,B8:B24)”. Changing the 3-D view One last alteration that can be very useful if you are using three-dimensional charts is changing the 3-D view. This can be especially useful with 3-D Pie Charts, as sometimes Excel sets these up with the smallest pie slices appearing at the back of the chart, so you may need to rotate the chart in order to view all of the data clearly. To alter the 3-D view, highlight the main body of the chart using the left mouse button and then click on the right mouse button. This will bring up the now familiar shortcut menu, and one 15 If this menu option is “greyed out” and not selectable, then you have not yet managed to highlight the data correctly, so try to select them again by clicking in the region of one of the data points. 16 Naturally the relevant ranges of cells do not have to be selected with the mouse, and this formula can be just typed in directly from the keyboard. 19 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 of the options that should be available is “3-D View...”. If no such option is provided on the shortcut menu, this means that either you have not selected the main body of the chart or that the chart you are trying to edit is not three- dimensional. The Format 3-D View dialogue box enables you to change the orientation, angle of elevation, and sometimes (depending on chart type) perspective of your 3-D chart. Transferring Excel Charts and Data into Word Charts and tables can of course be printed out from Excel directly (select the “Print...” item from the File menu) and then collated with a paper copy of a wordprocessed document. Alternatively you can copy and paste charts and ranges of cells from Excel into Word, which is usually preferable because it gives you far more control over how the charts, cells and text are integrated. To paste a chart into Word, first make sure that the chart is selected within Excel by clicking on it with the mouse (and if necessary use the black square selection handles to re-size it before you copy it). Then select “Copy” from the Edit menu (or from the right mouse button shortcut menu), which will copy the chart into the Clipboard. You can then minimise the Excel window (or type ALT+Tab in the usual way) and start up Word (if you haven’t done so already – if you have, just switch directly into Word). Next identify where in the Word document you wish to insert the chart, place the cursor there by clicking with the mouse and finally select “Paste” from the Edit menu, when the chart will be inserted as desired. You should now be able to create charts from the data in your worksheet, 20 ACOM 1010 Introductory IT Skills Introduction to Excel (Science students) Lecture 6 Appendix 1: Troubleshooting for Formulae There are various problems that can occur when entering a formula. If you can’t get a formula to work, check that: • • • • You have put an equals sign at the start of the formula Your typing is correct You have not entered a name (for an array of cells) which is undefined If you are using brackets, check that there are the same number of opening and closing brackets To help sort out what has gone wrong, here are the most common error messages, together with their meaning. Error Code Meaning ##### This shows that the cell is too narrow to display the error code – make the column wider. #DIV/0 The formula is trying to divide by zero. If you can’t see the problem in the formula itself, ensure that any names by which you divide have a non-zero value (N.B. blank cells tend to be treated as zero). #N/A No value is available. You are unlikely to get this message unless you use facilities beyond the scope of this booklet and use an Excel function which in the context fails to Enter a value. #NAME? Excel does not recognise a name used in the formula. Check your typing. If this doesn’t solve the problem, the Define Name dialogue box will show you which names have been defined. #NULL! You specified an intersection of two areas which do not intersect – not a common error! #NUM! There is a problem with a number in a formula. #REF! The formula uses a cell reference that is not valid. #VALUE! An argument or operand is of the wrong type. For example, you may have included an integer (e.g. 6) where the formula needs a real number (e.g. 6.1), or attempted to calculate with a cell containing text. 21 ACOM 1010 Introductory IT Skills 22 Introduction to Excel (Science students) Lecture 6
© Copyright 2026 Paperzz