You are on page 1of 72

Advanced Excel

techniques for
accountants

While great care has been taken in the preparation of this material, the author and the publishers assume no
responsibility for errors or omissions, or for the uses made of the material contained herein or the decisions
based on such use. No warranties are made, express or implied, with regard to the contents of this work, its
merchantability, or fitness for a particular purpose. The author shall not be liable for direct, indirect, special,
incidental, or consequential damage arising out of the use or inability to use the contents of this publication.
Trademark acknowledgements
Windows, PowerPoint and Excel are registered trademarks of Microsoft inc.
Screen shots reprinted by permission from Microsoft Corporation.

© The Knowledge Base www.tkb.co.uk


© The Knowledge Base www.tkb.co.uk
Contents
Animation test page ......................................................................................................................................................................................1 
1.  Functions and wizards .........................................................................................................................................................................2 
1.1  VLOOKUP()...............................................................................................................................................................................2 
1.1.1  Lookup_value .......................................................................................................................................................................3 
1.1.2  Table_array ..........................................................................................................................................................................3 
1.1.3  Col_index_num ....................................................................................................................................................................4 
1.1.4  Range_lookup ......................................................................................................................................................................4 
1.2  Conditional sum wizard .............................................................................................................................................................5 
1.2.1  Step 1 ...................................................................................................................................................................................6 
1.2.2  Step 2 ...................................................................................................................................................................................6 
1.2.3  Step 3 ...................................................................................................................................................................................7 
1.2.4  Step 4 ...................................................................................................................................................................................8 
1.2.5  Step 5 ...................................................................................................................................................................................8 
1.2.6  Step 6 ...................................................................................................................................................................................9 
1.3  OFFSET()..................................................................................................................................................................................9 
1.4  MATCH() .................................................................................................................................................................................10 
1.4.1  Checks and controls...........................................................................................................................................................10 
1.5  SUMIF() function .....................................................................................................................................................................11 
1.6  Array........................................................................................................................................................................................11 
1.6.1  Using an array formula with multiple criteria ......................................................................................................................12 
1.7  More on arrays and TRUE and FALSE ...................................................................................................................................13 
1.7.1  Array formulae explained ...................................................................................................................................................13 
1.7.2  Not just one dimensional ....................................................................................................................................................14 
1.7.3  So what? ............................................................................................................................................................................14 
1.7.4  Arrays and Boolean logic ...................................................................................................................................................15 
1.7.5  Arrays, SUMIF() and SUMPRODUCT() .............................................................................................................................16 
1.7.6  SUMPRODUCT() ...............................................................................................................................................................17 
1.7.7  SUMIFS() ...........................................................................................................................................................................17 
1.8  Text functions ..........................................................................................................................................................................18 
1.8.1  Introduction.........................................................................................................................................................................18 
1.8.2  Concatenating text .............................................................................................................................................................18 
1.8.2.1  Formula ................................................................................................................................................................................................18 

1.8.2.2  Function................................................................................................................................................................................................18 
1.8.2.3  Text and numbers.................................................................................................................................................................................18 

1.8.3  Other text functions ............................................................................................................................................................19 


1.8.3.1  Insert function categories......................................................................................................................................................................19 

1.8.3.2  Left, Right and Mid................................................................................................................................................................................20 

1.8.3.3  Search, Len ..........................................................................................................................................................................................21 


1.8.3.4  Value ....................................................................................................................................................................................................23 
1.8.3.5  Clean, Trim ...........................................................................................................................................................................................23 

1.9  Rounding .................................................................................................................................................................................24 


1.9.1  Rounding ............................................................................................................................................................................24 
1.9.2  Rounding to ‘000s ..............................................................................................................................................................25 
1.10  The Indirect function................................................................................................................................................................25 
1.11  User-defined functions ............................................................................................................................................................26 
2.  Linking to external data ......................................................................................................................................................................28 
2.1  Linking to an external file.........................................................................................................................................................28 
2.2  Query Wizard ..........................................................................................................................................................................28 
© The Knowledge Base www.tkb.co.uk
2.2.1  Step 1 – Choose Columns ................................................................................................................................................. 28 
2.2.2  Step 2 – Filter Data ............................................................................................................................................................ 30 
2.2.3  Step 3 – Sort Order............................................................................................................................................................ 30 
2.2.4  Step 4 – Finish ................................................................................................................................................................... 31 
2.2.5  External Data Range Properties ........................................................................................................................................ 32 
2.2.5.1  Refresh control..................................................................................................................................................................................... 33 
2.2.5.2  Change in number of rows ................................................................................................................................................................... 33 

2.3  Linking to an HTML page........................................................................................................................................................ 37 


2.3.1  Setting up a new web query .............................................................................................................................................. 37 
2.3.2  That’s refreshing ................................................................................................................................................................ 38 
2.3.3  Warning.............................................................................................................................................................................. 38 
2.4  Linking to individual cells in a worksheet ................................................................................................................................ 39 
2.4.1  Safety first .......................................................................................................................................................................... 40 
3.  Miscellaneous .................................................................................................................................................................................... 41 
3.1  Protecting Excel spreadsheets ............................................................................................................................................... 41 
3.1.1  To be sure, to be sure, to be sure...................................................................................................................................... 41 
3.1.1.1  Stage 1: unlock the data cells............................................................................................................................................................... 41 

3.1.1.2  Stage 2: protect the sheet .................................................................................................................................................................... 41 


3.1.1.3  Stage 3: protect the workbook.............................................................................................................................................................. 42 

3.1.2  But… .................................................................................................................................................................................. 42 


3.1.3  Allow users to edit ranges.................................................................................................................................................. 42 
3.1.3.1  Alternative protection............................................................................................................................................................................ 43 

3.2  Data validation lists ................................................................................................................................................................. 43 


3.2.1  Introduction ........................................................................................................................................................................ 43 
3.2.2  Managing multiple lists ...................................................................................................................................................... 43 
3.2.3  Copying data validation settings ........................................................................................................................................ 44 
3.2.4  Apply changes to all other cells ......................................................................................................................................... 45 
3.2.5  Dynamic lists...................................................................................................................................................................... 46 
3.2.5.1  Lookup_Value ...................................................................................................................................................................................... 48 

3.2.5.2  Table_array .......................................................................................................................................................................................... 48 


3.2.5.3  Row_index_num................................................................................................................................................................................... 48 

3.3  Data validation formulae ......................................................................................................................................................... 49 


3.3.1  Introduction ........................................................................................................................................................................ 49 
3.3.2  Accounts code ................................................................................................................................................................... 49 
3.3.3  Letters v. Numbers............................................................................................................................................................. 50 
3.3.3.1  Numbers............................................................................................................................................................................................... 50 
3.3.3.2  Letters .................................................................................................................................................................................................. 50 

3.3.4  AND() ................................................................................................................................................................................. 50 


3.3.5  But...................................................................................................................................................................................... 51 
3.3.6  More columns .................................................................................................................................................................... 52 
3.4  Paste special .......................................................................................................................................................................... 53 
3.4.1  Formulas ............................................................................................................................................................................ 53 
3.4.2  Values ................................................................................................................................................................................ 53 
3.4.3  Formats.............................................................................................................................................................................. 53 
3.4.4  Comments.......................................................................................................................................................................... 53 
3.4.5  Validation ........................................................................................................................................................................... 54 
3.4.6  All except borders .............................................................................................................................................................. 54 
3.4.7  Column widths ................................................................................................................................................................... 54 
3.4.8  Formulas and number formats........................................................................................................................................... 54 
3.4.9  Values and number formats............................................................................................................................................... 54 

© The Knowledge Base www.tkb.co.uk


3.4.10  Operations..........................................................................................................................................................................54 
3.4.11  Skip blanks .........................................................................................................................................................................54 
3.4.12  Transpose ..........................................................................................................................................................................54 
3.4.13  Paste Link...........................................................................................................................................................................55 
3.5  Pivot Table grouping ...............................................................................................................................................................55 
3.5.1  It’s about time .....................................................................................................................................................................55 
3.5.2  Manual grouping.................................................................................................................................................................57 
4.  Charts.................................................................................................................................................................................................58 
4.1  Graph on two axes ..................................................................................................................................................................58 
4.2  The ever changing lights of Balham ........................................................................................................................................59 
4.2.1  Introduction.........................................................................................................................................................................59 
4.2.2  Setting up the conditional format........................................................................................................................................59 
4.3  30 second graph in a cell ........................................................................................................................................................61 
4.3.1  Using the REPT() function..................................................................................................................................................61 
4.3.2  Automatic scaling ...............................................................................................................................................................62 
4.3.3  REPT() and conditional formatting .....................................................................................................................................62 
4.4  Pictures as fill effects...............................................................................................................................................................63 

Animations – click on the screen shots outlined in green to see an animation of the
feature. Left mouse clicks are highlighted in red and right mouse clicks in blue.
Office 2007 instructions are shown in orange text

© The Knowledge Base www.tkb.co.uk


Animation test page
If the animations do not work, please check to see which of the animations on this page does work and let us
know at simonh@tkb.co.uk . We will then send an appropriate version of the PDF.

WMV

AVI (Adobe 5 compatible)

Gif

© The Knowledge Base www.tkb.co.uk Page 1


1. Functions and wizards
1.1 VLOOKUP()
In this example, we will use VLOOKUP() to allocate a series of account codes and values to a set of
categories. First of all we need to set up a table listing the categories by code in order. Our categories table
is very simple, but we could make it more detailed just by inserting or adding further lines. Later we will use
the same categories table to show summaries by category using the Conditional Sum wizard. Note that for
the final line to work correctly, you will need to add an additional line at the bottom containing the upper limit
of the category.
Below is our table of categories. So that we can easily see what is happening, we will create this next to our
external data range, generally it would be better to locate it on a different sheet, so that changes to the
number of rows in our data range cannot affect the table.

Give this table the name ‘Categories’ by selecting G1 to H7 and choosing Insert, Name, Define (Formulas
ribbon, Defined Name group, Define Name) or by just typing the name into the 'Name Box' to the left of the
formula bar and pressing Enter:

Note that in Excel 2007 you can define the 'Scope' of the name by choosing 'Workbook' or the name of an
individual sheet to limit the scope to that sheet alone.
We are going to use Column D to show the category of each of our codes, so we type Category as the
heading, and click on cell D2.

Page 2 © The Knowledge Base www.tkb.co.uk


We will now use the ‘Insert Function’ button in the formula bar to set up our Lookup function. In versions of
Excel before Excel XP the screen is called 'Paste function' and the button lives on the standard toolbar.
We choose the Function category: ‘Lookup & Reference’ and then from the list of Function names choose
‘VLOOKUP’. This will ‘look up’ a value in a table by searching for a value in the leftmost column and then
returning a value from the same row in a different column. In our example we will be searching for a code in
our categories table, and returning the corresponding category description. Note that for lookups where you
need to find the intersection of a row and column in a table the lookup wizard will be very useful. This is an
add-in installed in the same way as the conditional sum wizard which we will look at shortly.

You will notice that as you select each function a brief description appears towards the bottom of the Insert
Function screen. Once we have found the function that we want to use we click OK:

Insert Function then allows us to enter the various ‘arguments’ that our particular function requires:

1.1.1 Lookup_value
We want to include the category description for the nominal code in column A, so for row 2 we select the
Lookup_value text box and click on cell A2. You will see the current value in A2 appears to the right of the
text box.

1.1.2 Table_array
Here we define the area of the table that we will be looking up our categories from. We defined the name
‘Categories’ for this table of data, so we can just type in that name, again you will see that the contents of the
Categories range appear to the right.

© The Knowledge Base www.tkb.co.uk Page 3


1.1.3 Col_index_num
This argument defines which column of our lookup table provides the data that we want to display in our cell
– in this case it is the second column, so we enter 2.

1.1.4 Range_lookup
This is an optional argument and can be recognised as such because, unlike the other argument
descriptions, it is not shown in bold. If we leave it empty, or enter a value of ‘True’ the lookup will find the
match equal to or greater than the value being looked up, but less than the next item in the table – i.e. 270
will use 200 from the lookup table because 270 is greater than 200 and less than 300. The lookup table
needs to be sorted or entered in ascending order for the function to work correctly. If we set this argument to
‘False’ the function will look for an exact match and return #N/A if it can’t find it.
We want the nearest match so we leave this argument blank.
That’s all the arguments and you can see the value ‘Sales’ displayed to the bottom of the Insert Function
screen so that we know the function is producing the anticipated answer. We press the OK button to enter
the formula into cell D2.

Again we can double click the fill handle at the bottom right hand corner of D2 to copy the formula down to
the end of our table:

As you can see, each of the codes now has a category added to it – we could use this in a Pivot Table for
example to group the codes and values, or in conjunction with the SUMIF() function to create individual
summary totals of each category.

Page 4 © The Knowledge Base www.tkb.co.uk


1.2 Conditional sum wizard
We are going to look at an alternative method of summarising our data. This time we will add totals to the
right of our categories table. To do this we will be creating array formulae which we will look at in more detail
later. Generally these are quite complex to create and have to be saved in a particular way. However we will
use one of the Excel Add-Ins – the Conditional Sum Wizard to do the work for us.
Before we can use the Conditional Sum Wizard we must make sure that it is installed. It is an Add-in, so we
will go to Tools, Add-ins (Office button, Excel Options, Add-Ins, Manage 'Excel Add-ins', Go button) and
make sure the Conditional Sum Wizard is ticked:

First we will enter the heading ‘Total’ in cell I1, and then select cell I2:

We then choose Tools, Wizard (Formulas ribbon, Solutions group, Conditional Sum) and, if we installed our
Add-In correctly, we should find we have the option ‘Conditional Sum Wizard’

© The Knowledge Base www.tkb.co.uk Page 5


1.2.1 Step 1

In the first step we define the range of cells to be used to calculate the totals, in our case cells A1 to B41 –
note that we need to include the column headings. Now on to step 2:

1.2.2 Step 2

Now the complicated bit! First of all we have to decide which column to sum – as you can see the column
heading are used here, and we obviously wish to use the Amount column.
We then have to define the range of codes for which we want to calculate the sum. We are entering the
formula in cell I2, which is the Sales cell in our categories table, so we need to define the range of codes that
make up sales. In our case this is codes 0 to 99. So we enter our first condition as Code >= (greater than or
equal to) 0. We then click the Add Condition button to add this condition:
As you can see, it appears in the conditions box:

Page 6 © The Knowledge Base www.tkb.co.uk


We now need to add a further condition to restrict the sum to codes below 100, and again we click Add
Condition:

Now onto Step 3:

1.2.3 Step 3

On this screen we choose whether to just enter our formula in a cell, or also to enter the conditional values. It
is one of the important concepts of spreadsheet design that you shouldn’t mix data and logic in a cell, so we
will copy the conditional values as well, and then our formula will contain references to the cells, rather than
© The Knowledge Base www.tkb.co.uk Page 7
the values themselves. This will also make it easier to copy the formula to the other rows. So we choose
‘Copy the formula and conditional values’ and click the Next button:

1.2.4 Step 4

We are going to use the existing categories table, which already holds the code ranges we need to use, so
the lower limit will go to G2 as above, Because there is already a value in G2 we will be asked to confirm that
we wish to overwrite it. Hopefully we are overwriting 0 with 0 so we will click the ‘Yes’ button.

1.2.5 Step 5

Now we enter the cell to contain the upper limit, again this is already part of our table in cell G3, and we
should be overwriting 100 with 100, so we can click yes again:

Page 8 © The Knowledge Base www.tkb.co.uk


1.2.6 Step 6

Finally we enter the formula itself in cell I2, and click Finish:

Once more we can double click the fill handle to copy the formula to the end of the table:

1.3 OFFSET()
OFFSET() is used to return the contents of a cell a given number of rows and/or columns from another
designated cell. In the example below OFFSET() has been used to set the contents of the summary in
column B to the figures for a particular month.

© The Knowledge Base www.tkb.co.uk Page 9


1.4 MATCH()
Here MATCH() is used to find the value '31/05/2006' in the range of column headings. It returns the 'position'
of the matching value in the list, in this case '5'. This value is then used in conjunction with the OFFSET()
function to return the values from the May column.

1.4.1 Checks and controls


When working with external data and formulae such as these it is always advisable to build in checks and
totals to ensure that changes in the external data have not created problems in dependent formulae. You
could, for example, include sums in I8 and B42 to make sure the summary total is the same as the total of
the external data amount column.

Page 10 © The Knowledge Base www.tkb.co.uk


1.5 SUMIF() function
The very useful SUMIF() function allows us to find the total for a range of cells, but, unlike the simpler SUM()
function, includes the capability of using a 'criteria' to restrict the cells included in the total to those that match
that criteria. A simple example should make this clearer:

Here we have a small set of values analysed by department. In cell E2 we have used the SUMIF() function to
total the values for department A. SUMIF() has three arguments:
• Range: the range of cells that we are going to compare against the criteria. In our case we want to
use the cells containing the department references – $A$2:$A$11. Because we want to copy the
formula to other cells, we have made the references in Range absolute – note that it would make the
formula easier to enter and to understand if we were to define names for the ranges A2:A11 and
B2:B11 and use those names in the formula;
• Criteria: the value or expression to be compared with each cell value in Range. We have pointed our
criteria to cell D2, so whichever value we enter in D2 will be used in the comparison – as you can
see this is currently 'A';
• Sum_Range: the range of cells to sum. The Sum_Range must correspond in shape to Range – so
that where the criteria is matched by a cell in Range, SUMIF() will include the cell value on the same
row in the Sum_Range area. If you don't specify a Sum_Range then the cells in Range will be
summed – obviously not what we want to do in this case. Again we have used absolute references
to $B$2:$B$11.
In our example we have copied our SUMIF() formula down to the next two cells so that we can enter other
department criteria in D3 and D4 and produce the totals for those departments.
If you examine the text to the right of the Range and Sum_Range text boxes you will notice that it contains
the contents of the specified range of cells, separated by semi-colons and surrounded by curly brackets or
braces. These braces are significant as they are used whenever Excel needs to work with an array of several
different cells or values.

1.6 Array
So, our SUMIF() function actually works with arrays of cells in the Range and Sum_Range arguments, but
mercifully protects us from needing to worry about the complexities of working with arrays. Let's see if we
can achieve the same result as using SUMIF() but by using an array formula rather than a function. This is
the suggested formula:
=SUM($B$2:$B$11*($A$2:$A$11=D2))

© The Knowledge Base www.tkb.co.uk Page 11


There is one very important thing to remember when entering or editing array formulae – you must accept
the completed formula by pressing Ctrl-Shift-Enter not just Enter, otherwise your formula will revert to a
normal formula and will not work properly. For this reason, if you do use array formulae, you may well want
to ensure that the worksheet is protected and the formula cells locked to prevent someone inadvertently
converting them back to normal formulae and getting the wrong answers.
When you do press Ctrl-Shift-Enter, braces will be added to the formula to make it into an array formula:

Let's look at our formula in more detail. The important bit is:
$B$2:$B$11*($A$2:$A$11=D2)
As part of an array formula, this will look at each of cells B2 to B11 in turn and multiply the value by whether
the corresponding cell in A2 to A11 is equal to whatever department criteria we enter in D2. If there is a
match the value will be multiplied by 1, if there is no match it will be multiplied by zero and therefore, of
course, not included. Note that the ($A$2:$A$11=D2) bit is surrounded by brackets. In order to total the
range of matching cells we need to put the whole of this formula within a SUM() function and save it as an
array formula as described above.

1.6.1 Using an array formula with multiple criteria


It may seem that all we have achieved here is to replace the relatively straightforward SUMIF() function with
a much more complicated, and error-prone array formula. In fact, if all we needed to do was to sum a range
based on a single criteria than SUMIF() would be the easier solution. However, array formulae come into
their own when we need to work with multiple criteria. SUMIF() works well with a single criteria but doesn't
allow for the inclusion of more than one criteria (unless you include an array within the SUMIF() arguments).
In contrast, the array formula enables additional criteria to be added with relative ease.
Here is an example:

Page 12 © The Knowledge Base www.tkb.co.uk


We have added 'Office' columns to the data area and the criteria area. The array formula has then been
extended to add the second condition:
*($B$2:$B$11=F2)
We have multiplied our value range by both conditions. This operates as an 'AND'. For the individual cell
value to be included in the total, both the Department AND the Office must match the criteria, this is because
each condition returns either TRUE or FALSE.

1.7 More on arrays and TRUE and FALSE


1.7.1 Array formulae explained
First of all, let's explain an array more fully. An array is a collection of individual values. At its simplest this
could just be a list such as 1,2,3. It is rather a long-winded way of entering 1,2,3 in three Excel cells, but if
you select three cells in a row and type in ={1,2,3} and then use Ctrl+Shift+Return to accept the entry, you
will create a block of three array formulae that return the values 1, 2 and 3:

This simple, and probably fairly useless, example can demonstrate a few important features of array
formulae. Firstly, when we referred to an array within a formula we had to type in the curly brackets {}, but
the curly brackets at the start and end of an array formula are not typed in, but created automatically, when
you press Ctrl+Shift+Return. Secondly, if you edit an array formula and then save it by pressing Return
rather then Ctrl+Shift+Return, the formula will revert to an ordinary formula, without the beginning and ending
curly brackets, and it will no longer operate as an array formula. Thirdly, if you try and edit just one of the
cells, Excel will tell you that you can't change one part of an array:

© The Knowledge Base www.tkb.co.uk Page 13


1.7.2 Not just one dimensional
Our example used a simple one dimensional array. By separating the values with commas we created a
horizontal array, had we used semi-colons it would become a vertical array:

We can create a two dimensional array by combining the commas and semi-colons:

1.7.3 So what?
So, all very interesting, but how can arrays be used in practice? Let's consider the following example of two
sets of figures that we need to compare:

Page 14 © The Knowledge Base www.tkb.co.uk


As you can see, there are two compensating errors. If we wanted to check whether the figures agree, we
couldn't just compare the sum of each column as they would be the same. We could use an array formula to
calculate the number of values that don't agree. What we need to do is to check A1 against B1, then A2
against B2 all the way down to A6 and B6.
We could easily do this with six IF() functions, each comparing a pair of values, as shown below:

More elegantly, we could use an array formula to compare the six values, and sum the number that aren't
equal, in a single cell. To do this, we replace the individual comparison in the IF() statement with the vertical
arrays, so:
=IF(A1=B1,0,1)
Becomes:
=IF(A1:A6=B1:B6,0,1)
We need to sum the resulting values:
=SUM(IF(A1:A6=B1:B6,0,1))
and then use Ctrl+Shift+Return to save it as an array formula:

The effect of this array formula is to compare each item in the first array with its corresponding item from the
second array – if they are equal the IF() statement returns 0, if they are not equal it returns 1. The result of
the six individual calculations is then totalled by the SUM() function to give us our total of 2 differences.

1.7.4 Arrays and Boolean logic


It can often be simpler and more elegant to use Boolean logic rather than the IF() function. Boolean logic is
all about what happens when you work with True and False values. The first part of the IF() function is a
statement that evaluates to True or False, but such statements can be used without using IF().
Here is our earlier example with column D now containing the A1<>B1 without the IF() function. As you can
see this returns a series of TRUE and FALSE values:

© The Knowledge Base www.tkb.co.uk Page 15


The essence of using Boolean logic is the following table of values:
FALSE*FALSE = FALSE (0*0=0)
TRUE*FALSE = FALSE (0*1=0)
FALSE*TRUE = FALSE (1*0=0)
TRUE*TRUE = TRUE (1*1=1)
As you can see, only a TRUE multiplied by another TRUE gives a result of 1 rather than zero.
Excel has some useful functions for working with TRUE and FALSE values. AND() evaluates a collection of
logical values and returns TRUE only if they are all TRUE, whilst OR() returns TRUE if any one is TRUE. So
effectively AND() corresponds with multiplying the values together, and OR() with adding them.
In our example:
=AND(D1:D6)
would return FALSE unless all the values were TRUE whilst:
=OR(D1:D6)
would return TRUE if at least one of the values was TRUE
We can use this to simplify our array formula:
{=AND(A1:A6=B1:B6)}
This formula should only return TRUE if all the values agree.
A word of warning: John Walkenbach is an internationally renowned Excel expert and his excellent range of
books on Excel Formulae contain some very detailed chapters on array formulae. He points out that AND()
and OR() do not work like other functions do in an array, since they just return a single value. As far as I can
work it out, turning an AND() or OR() formula into an array formula has no effect unless the formula contains
a statement that compares arrays of values, in which case the array version will work and the non-array one
won't.
An example might help:

Here we are contrasting the use of LEN() and AND() in array formulae. In an array, LEN() which returns the
length of a text string, creates an array with an entry for each cell in the source range. However, AND()
returns just a single value based on an overall evaluation of each cell in the range. Here we see both entered
in all four cells. LEN() returns the values for each cell in turn, whilst AND() returns the overall FALSE
whichever cell it is entered into.

1.7.5 Arrays, SUMIF() and SUMPRODUCT()


Often, you can avoid using an array formula by using either SUMIF() or SUMPRODUCT(). Let's revisit our
simple example where we used SUMIF() successfully. Here we just wanted to total our values by

Page 16 © The Knowledge Base www.tkb.co.uk


department. In this example we used array formulae and Boolean logic to calculate our subtotals. We are
multiplying the values in B2 to B11 by the statement that the departments in A2 to A11 are equal to the
contents of D2, D3 and D4 which contain our different departments:

We can make it a bit easier to understand by naming our areas – A2:A11 as department and B2:B11 as
value. Our array formula now becomes:
{=SUM(Value*(Department=D2))}
Whilst this works, it was more straightforward just to use the SUMIF() function:
=SUMIF(Department,D2,Value)
So far, so good for SUMIF(), but as we have seen, if we make our example a bit more complex then SUMIF()
won't be able to cope. Here we have added an 'Office' category to our table of data:

If we now need to sum the values based on a combination of department and office, then we can't use
SUMIF() which can only cope with a single criteria. We can extend our array formula by adding a second
condition – once again we have given names to the different ranges:
{=SUM(Value*(Department=E2)*(Office=F2))}

1.7.6 SUMPRODUCT()
Although we can't use SUMIF(), there is another of the SUM() family that will work – SUMPRODUCT(). This
function multiplies its arguments together and sums the result. The arguments can be arrays, as long as they
all have the same dimensions, which is why we can use this function in this case:
=SUMPRODUCT(Value*(Department=E2)*(Office=F2))
You may be wondering why we couldn't enter the three elements as different arguments rather than
multiplying them together manually since SUMPRODUCT() is meant to do the multiplication for us.
SUMPRODUCT(), like the other SUM() functions, doesn't 'coerce' non-numeric values to allow them to be
evaluated as numbers, so our statements are treated as TRUE and FALSE rather than 1 and 0. We could
rewrite the SUMPRODUCT() function with separate arguments by coercing the FALSES and TRUES by
adding 0 or multiplying by 1:
We have combined the two coercion methods in the following example:
=SUMPRODUCT(Value,(Department=E2)+0,(Office=F2)*1)

1.7.7 SUMIFS()
Excel 2007 has introduced a new member of the SUM() family – SUMIFS(). This works in the same way as
SUMIF() but allows the entry of multiple criteria as a series of pairs of ranges and corresponding criteria:
© The Knowledge Base www.tkb.co.uk Page 17
=SUMIFS(Value,Department,E2,Office,F2)
Of course, to use SUMIFS() not only do you need to be using Excel 2007, but so does anyone else that you
might send your spreadsheet to.

1.8 Text functions


1.8.1 Introduction
The Excel Text functions can be very useful when working with data from accounting applications that is not
quite in the format required for the Excel analysis or presentation that we need.

1.8.2 Concatenating text


1.8.2.1 Formula
First of all let’s deal with combining text in two separate cells into a single cell. There are two principal ways
to achieve this. Perhaps the simplest is to use the ‘&’ within an Excel formula:

In our example we have typed three items of text in columns A, B and C. In cell D1 we have entered the
following formula to combine all three into a single cell:

=A1 & " " & B1 & " " & C1

1.8.2.2 Function
Alternatively, there is an Excel function that concatenates text in this way. Unsurprisingly it is the
‘Concatenate’ function.
In the following screen shot we have used ‘Insert Function’ to enter the required details. Note that in order to
include spaces between the items of text, we have included “ “ between each pair of cells. Using the Insert
Function screen, you just need to enter a space in the appropriate text box – Excel will add the speech
marks for you:

1.8.2.3 Text and numbers


So far so good, now let’s see how we cope with combining numbers and text. If we just want the number
without worrying about the number format, then we can use exactly the same formula as for two items of
text. Here we have included some ‘literal’ text in the formula together with a number in a cell:
Page 18 © The Knowledge Base www.tkb.co.uk
As you can see the format is not ideal:
In the following example we have used the ‘Text’ function to format the number in the cell:

Note that you can also use named ranges. So if we name cell B3 as ‘profit’ we could write the formula as:

="Profit is " & TEXT(profit,"£#,##0")


Note that we have included a space after the ‘is’ and before the “ so that the number does not follow on
immediately from the text.

1.8.3 Other text functions


1.8.3.1 Insert function categories
To see the text functions available in Word, select Insert, Function and then choose the ‘Text’ category (note
that the examples shown are from Excel XP, other versions’ screens are slightly different):

As you can see there are lots of text functions, we will look at a few in detail, but if you want to explore all of
them, just scroll through the list using the down arrow key. As you select each function in turn you will see a
brief description of what it does towards the bottom of the screen. For more details, click on the ‘Help on this
function’ link:

© The Knowledge Base www.tkb.co.uk Page 19


1.8.3.2 Left, Right and Mid
This group of functions can be used to return specific sets of characters from a text string. As you would
imagine, Left is used to return a certain number of characters from the beginning of a text string, Right is
used to return characters from the end and Mid to return characters from anywhere within the text string.
As an example, we will look at some nominal ledger codes. We will assume that the first two characters
represent the company, the next three the branch, and the last four the type of expense or income:

First of all we will use the Left function to list the first two characters in the company column. We can either
use Insert, Function or just type the function in directly if we know the required syntax:

=LEFT(A7,2)

Now let’s use Right in a similar way to sort out the four characters from the end of the code:

=RIGHT(A7,4)

Page 20 © The Knowledge Base www.tkb.co.uk


As you can see, the syntax of Left and Right are very similar, just referring to the cell holding the code and
the number of characters. The final function that we will look at in this section is ‘Mid’ and the syntax for this
one is slightly more involved because we need not only to specify the number of characters, but also from
which character to start. For this reason you may find it easier to use Insert, Function:

This should create the following formula:

If we now copy the three formulae down to the end of our list, we can see how our text string has been split
into the three different sections:

1.8.3.3 Search, Len


Now let’s consider a slightly more difficult situation. In the following example we have a description and an
amount in the same cell, but the two are always separated by a hyphen:

© The Knowledge Base www.tkb.co.uk Page 21


Because neither the length of the text or the figure are necessarily consistent, we can’t use Left, Right or
Mid. However, we can instead use the hyphen to work out where the description ends and the number
begins. To do this we must first identify how many characters from the left there are before the hyphen.
To do this we use the ‘Search’ function. Here is the function screen for Search:

Note again that we can just type the hyphen into the ‘Find_text’ box and Excel will automatically add the
speech marks. Note also that there is the option to specify the character position at which you want to start
the search. This is useful if you need to locate more than one similar character – once you have found the
first, you can start the next search from one character position higher. Our example is a simple one that
doesn’t use the ‘Start_num’ argument and, as you can see, it returns the position of the hyphen as character
6.

=SEARCH("-",A13)
We can now ‘nest’ the Search function within the ‘Left’ function to retrieve the description:

=LEFT(A13,SEARCH("-",A13)-1)
In order to exclude the hyphen itself we have subtracted 1 from the result of search. If we copy this formula
down our list we can see that it achieves the desired result:

Now to deal with the amount. Whilst we can use Search to find the starting position, we don’t yet know how
long the amount is. We can work this out using the ‘Len’ function. ‘Len’ is a very simple function with just one
argument - the text string, or cell containing the text string, that we wish to find the length of:

=LEN(A13)
This tells us how long the text is in total, and we have already used Search once to find the position of the
hyphen. By combining Len and Search we can calculate how many characters follow the hyphen:

=LEN(A13)-(SEARCH("-",A13))

Page 22 © The Knowledge Base www.tkb.co.uk


In the case of “Sales-10000” Len will return 11, the hyphen is at position 6, so 11-6 = 5, the number of
characters in the amount.
We can use this with the ‘Right’ function to pick out the amount:
=RIGHT(A13,LEN(A13)-(SEARCH("-",A13)))
Again we can copy this formula down the list:

1.8.3.4 Value
As you can see above, whilst we have indeed separated out the amount characters, Excel is still treating our
text as text and if we used Sum to total the Amount column we would get zero:

We need to convert the text ‘amounts’ into proper numbers. To do this we use the function Value. We will
create a new column called ‘Amount2’ and enter a value function to convert the three items in our list to
numbers. Here is the formula for cell D13:

=VALUE(C13)
We can now copy this down our list and use Sum again to total our new column:

As you can see, the text values are now treated as numbers and Sum works correctly.

1.8.3.5 Clean, Trim


These two functions can be used to remove unwanted characters from text. Sometimes, if you import text
from other sources, you may end up with non-printing characters, such as carriage returns – Clean will
remove these. Trim can be used to get rid of extraneous spaces:
In the following example we have part of an address that includes multiple spaces between ‘High’ and
‘Street’ and a carriage return character to separate the lines of the address.
In column B we have used Trim to get rid of the extra spaces:

=TRIM(A19)
and then in column C we have used Clean on the result to remove the carriage return:

=CLEAN(B19)
© The Knowledge Base www.tkb.co.uk Page 23
Note that the Trim function leaves a single space between High and Street, but that the Clean function
removes the carriage return entirely.

1.9 Rounding
1.9.1 Rounding
In this example of the use of the ‘Round’ function, we will use ‘Round’ to help with the issue of profit share
allocation..

Here is the typical problem, £100 divided three ways, with figures formatted to show no decimal places.

Normal £

Total Profit 100

Share 1 1/3 33

Share 2 1/3 33

Share 3 1/3 33

100

Here, the shares are calculated simply by multiplying the total by the share:

=$C$2*B3

If we sum the shares we get 33+33+33 apparently being equal to 100.

In this example we use the Round function

Using 'Round' £

Total Profit 100

Share 1 1/3 33

Share 2 1/3 33

Share 3 1/3 34

100

The shares are calculated as follows:

=ROUND($D$2*B3,0)

The last share is simply the total less the other shares:

=D2-SUM(D3:D4)

Page 24 © The Knowledge Base www.tkb.co.uk


1.9.2 Rounding to ‘000s
The ‘0’ argument in the Round function above simply means 0 decimal places To show two decimal places
you would use the number 2 for example.

This number can be negative. = Round(A1,-3) will round the figure in cell A1 to thousands. Remember to set
the custom number format to something like:

#,###,_);[Red](#,###,);-??

1.10 The Indirect function


Excel’s Indirect function allows the creation of a formula by referring to the contents of a cell, rather than the
cell reference itself – hopefully an example will make this clearer.
To refer to cell A2 on a sheet named ‘Cuddly Toys’ we would use a formula like this:
='Cuddly toys'!A2
However, sometimes it would be useful to be able to change a whole series of references to, for example, a
different sheet.
We could type the sheet name into a cell on our main sheet, say A1. We could then write a formula to refer
to cell A2 on the sheet typed into cell A1.
If we simply type:
=A1!A2
Excel, not unreasonably, looks for a sheet named A1 and fails to find it.
However, we can use the Indirect function instead. Here is the screen from the Insert Function dialog for
Indirect:

"'" & $A$1 & "'!A2"


Our Ref_text entry is a little confusing, so we have highlighted the pairs of speech marks in different colours.
We have two items of text, and sandwiched in between them, an absolute reference to the contents of cell
A1 – as you can see this correctly returns the contents of that cell – Cuddly toys. The ampersands are used
to join the 3 elements of our Ref_Text together. The first text section simply holds a single apostrophe – this
is necessary because if our sheet name contains a space, it must be surrounded by apostrophes to be
correctly identified. The second section contains an absolute reference to cell A1 – the cell where we type
the name of our sheet. The third text section contains the closing apostrophe for the sheet name, together
with the exclamation mark that separates sheet name from cell reference, and the cell reference itself – A2.
This works well to return the contents of cell A2 on our cuddly toys sheet, and if we were to type in
‘Boardgames’ for example, it would automatically return the contents of cell A2 on a sheet named
‘Boardgames’.
However we do have a problem left to solve. We need to refer to many cells on the price list sheets, but if we
copy our Indirect cell, the reference to A2 doesn’t change, because it is just text. We can solve this by using
a row/column style reference instead of A2:

© The Knowledge Base www.tkb.co.uk Page 25


"'" & $A$1 & "'!RC"
Note that we have to set the ‘A1’ argument of the function to ‘False’ to use this reference. RC will return the
current row and column – so a formula in cell A2 will refer to A2 on cuddly toys, A3 to A3 and so on. If we
need to refer to a different cell we would add numbers in square brackets after R and C. So R[1]C[1] would
look at the cell one row down and one column right for example.
An animated version of the use of INDIRECT() is one of several topics covered in the 'lunchtime learning'
section of our website:
http://www.tkb.co.uk/excelprofit.htm#Indirect%20function

1.11 User-defined functions


When you record a macro in Excel you end up with a 'sub-procedure'. However, you can also create
functions than can be 'called' from macros or cells in the spreadsheet, just like Excel's built in functions.
To create a function, in the Visual Basic editor – Tools, Macro, Visual Basic Editor (Developer ribbon, Code
group, Visual Basic) either open an existing module or choose Insert, Module, then Procedure and choose
Function:

Page 26 © The Knowledge Base www.tkb.co.uk


Enter the following code, and click on Debug, Compile VBA Project to check the code:

Function ValCond(TestCell, dr$, cr$)

Application.Volatile

If TestCell.Value > 0 Then ValCond = dr$ Else ValCond = cr$

End Function

To use the function enter =ValCond(A5,”loss”,”profit”) in a cell in the spreadsheet - the text profit or loss
should be returned depending on the value in cell A5. The 'Application.Volatile' line ensures that the function
will be recalculated automatically when the underlying data is changed.
You will find that VALCOND() is also included in the 'User-defined' section of the Insert Function screen.

© The Knowledge Base www.tkb.co.uk Page 27


2. Linking to external data
2.1 Linking to an external file
Now let’s look at the recommended way of getting at external data wherever possible – the use of the
Get/Import External Data option to create a dynamic link to the file. Note that Excel 2007 has a series of
options to link directly to particular types of data file; for the sake of compatibility we are going to use the
'Other Sources' option because the way it works is closest to earlier versions).
Choose Data, Get/Import External Data (Data ribbon, Get External Data), we will choose to create a New
Database Query (Excel 1997: New Query) (From Other Sources, From Microsoft Query):

The first screen we see let’s us choose the type of data file we want to connect to. The options you see will
depend on the version of Excel that you are using, your original set-up choices, and any data sources you, or
software installations, have installed. We want to connect to a text file, so we choose the Text Files option.
Note that if we had already created a query to extract the information we required we could access this by
clicking the Queries tab. In later versions of Excel there is also a tab for OLAP Cubes but we will keep the
tutorial reasonably simple by sticking with our Text files data source on the Databases tab, and clicking the
OK button. This will launch the Query Wizard.

2.2 Query Wizard


2.2.1 Step 1 – Choose Columns
The first screen of the Query Wizard lets us choose the text file or files we want, and the particular columns.

You can see that our accounts files have been found successfully – we will use accounts.csv.

Page 28 © The Knowledge Base www.tkb.co.uk


Note that generally the wizard will look for the files in the current directory (i.e. the directory or folder that
comes up when you choose File, Open. You may need to go to File, Open and navigate to the folder where
your text file is located, and then run the Get External Data routine. The instructions as to where to look for
the data files are part of the properties of the Data Source itself, how you get at this will depend on your
operating system, but generally will be found in Control Panel under ODBC (Open DataBase connectivity)
Data Sources or Data Sources (ODBC). Here we are looking at the Setup for the Text Files Data Source –
note that the Use Current Directory option is ticked. If this option is not set, then you can use the Select
Directory button to choose a specific directory.

So, assuming we have found our files, we can now choose our columns of data. In fact in our case we need
both the columns in accounts.csv, so we could just click on ‘accounts.csv’ and press the > button to include
both the columns in our query. If we had wanted to choose particular columns, then we would click the plus
sign to the left of accounts.csv to display the columns, and then select each one you want in turn and press
the > button.

Here is the screen with both columns included. We have also selected the ‘Amount’ column and pressed the
‘Preview Now’ button to enable us to preview the data in the column:

Now we press the next button to move onto the next step of the wizard:

© The Knowledge Base www.tkb.co.uk Page 29


2.2.2 Step 2 – Filter Data

On this screen we could set up a series of criteria to limit the data we link to. For example if our file included
profit and loss and balance sheet codes, we could restrict the lines we use to those with profit and loss
account codes in them.
Here is an example, but in our case there is no need to set a filter as we have only included the profit and
loss codes in the file:

So, with no filter set, we go on to the Next step:

2.2.3 Step 3 – Sort Order

We can choose to sort the data including sorts within sorts. We will sort by code:

Page 30 © The Knowledge Base www.tkb.co.uk


2.2.4 Step 4 – Finish

On the last stage of the wizard we can choose to send our data directly to our Excel spreadsheet, look at the
data in Microsoft Query, and from Excel 2000 onwards, Create an OLAP cube. In addition we could save the
query to make it easier to retrieve the same data on a future occasion.
We will save the query as Accounts:

As our data is very simple, we will also just choose to Return Data to Microsoft Excel, so we leave this option
selected and press Finish:
We are asked where to put our data – we will choose to put it into the Existing worksheet in cell A1:

© The Knowledge Base www.tkb.co.uk Page 31


Note that there is a Properties button, we need to look at the Properties, but we will do so once we have
linked to the data, so we just press OK at this stage:
Here is our data:

Note that the Code is being treated as a number. An External Data toolbar may automatically be displayed.
You can click the 'Properties' button on this toolbar, or right click in the data area and choose 'Data Range
Properties'.

2.2.5 External Data Range Properties


Options may vary slightly in different versions. In particular in Excel 2007 there is a 'Prompt for file name on
refresh' option at the top of the Refresh control section which helps overcome problems of spreadsheets
being unable to find the data when moved around.

We will change the Name to Accounts. This will make it easier to refer to the table of data in future formulae.
We won’t look at all the other options in detail, but will pick out some important ones:

Page 32 © The Knowledge Base www.tkb.co.uk


2.2.5.1 Refresh control
If our accounting data was sufficiently dynamic, we could cause it to be automatically refreshed every so
many minutes. More realistic may be to ensure that the data is always refreshed when the workbook file is
opened.

2.2.5.2 Change in number of rows


There are three options with regard to what to do when the number of rows in the external data file increases
or decreases.
1. You can insert cells for new data, and delete unused cells, thus preserving the position of any
content to the left or right of the data range;
2. You can insert entire rows for new data, and just clear the contents of unused cells, or:
3. You can overwrite existing cells with the new data and clear unused cells.
The last option is an important one: Fill down formulas in columns adjacent to data. If you wanted to create
formulae for each item from your data file, for example you wanted to manipulate a hierarchic code to split it
into different sections, you could enter the appropriate formula in the column immediately to the right of your
data range, select this option, and then if new rows are added to the external data, the formula will
automatically be filled down to all the new rows. We will set this option and choose OK:

To demonstrate the fill down formulas option, and show how to refresh our data, we are going to add a
column to the right of the External data range, and add a row to our data file.
Firstly we will type in ‘Department’ in cell C1. We will then assume that the rightmost digit of the code defines
the Department. So in C2 we will enter =RIGHT(A2). This will return the rightmost character in cell A2 – in
this case 0:

© The Knowledge Base www.tkb.co.uk Page 33


Now we will find our data file using Windows Explorer and right click it.

From the object menu we will choose Open With, and choose the Notepad Option:

Page 34 © The Knowledge Base www.tkb.co.uk


We will click at the right hand side of the 004 line:

and press Return to insert a new row:

We will now type in: 005,-200000

© The Knowledge Base www.tkb.co.uk Page 35


Don’t press Return after this, just choose File Exit, and click ‘Yes’ to save the changes.
We have now added a new row to our data file.
Back to Excel, we click in our external data range, and then press the refresh button (the red exclamation
mark) on the data range toolbar or right click, Refresh:
Not only should you find that your 005 row is included in the correct place:

but if you look at the bottom of the data table, you should find that there are now 41 rows, and your column C
formula has been copied down to row 41:

Page 36 © The Knowledge Base www.tkb.co.uk


2.3 Linking to an HTML page
As well as linking to data in conventional database files, Excel can link to tables of data in a web page.

2.3.1 Setting up a new web query


First we select the cell in which we want our web data to appear – in our case cell A1 - and then choose
Data, Import External Data, New Web Query (Data ribbon, Get External Data group, From Web):

We paste the required web address into the ‘Address’ text box, and click ‘Go’. The web page is displayed in
the dialog box, and each available table of information is marked. We click on the data that we want.
The selected data will be highlighted and ‘ticked’ with a green tick. We click on the Import button, and Excel
prompts us as to where we want to enter the data, we choose A1:

When we click the OK button our data is returned from the Internet to our spreadsheet:

© The Knowledge Base www.tkb.co.uk Page 37


2.3.2 That’s refreshing
We have created our link to the external web data. We can right click anywhere in our external data area and
click on the 'Refresh data' button. We can also choose ‘Data Range Properties’ from the right click menu to
set automatic refresh options:

As you can see, the Data Range Properties include a section for ‘Refresh control’. You can choose to refresh
the data every so many minutes, and to ‘Refresh data on file open’ – this is the option that we have chosen.
Whenever the spreadsheet file is opened, it will retrieve the up-to-date information from the Internet. As
always there is a potential security issue here, and you may see the following message when such a
spreadsheet is opened:

Obviously, depending on your knowledge of the spreadsheet in question you would choose whether to
‘enable’ Excel to retrieve the information from the Internet.

2.3.3 Warning
Whilst this technique can be very useful, you do have to bear in mind that, if you are linking to an external
web page, you will be dependent on the design of the page remaining constant. If the location of your table
of data changes or is removed altogether, you will have to redo your link.

Page 38 © The Knowledge Base www.tkb.co.uk


2.4 Linking to individual cells in a worksheet
We can include links to individual Workbook cells in a Word document. Here we have a Word document with
an appropriate line of text:

We want to insert the value from our Excel spreadsheet between the ‘to’ and the full stop.
First we go to our Excel sheet, click on cell B2 and choose Insert, Name, Define (Formulas, Defined Names
group, Define Name) Type in ‘EastSales’ and Add this to our list of names or just type the name into the
'Name Box' to the left of the formula bar and press Enter:

Note that in Excel 2007 you can define the 'Scope' of the name by choosing 'Workbook' or the name of an
individual sheet to limit the scope to that sheet alone.
It is always advisable to link to a named cell rather than using the cell reference, as the link should still pick
up the correct cell if changes to the spreadsheet move the cell’s absolute position.
We click on OK, right click the cell and choose Copy. Now we go back to the Word document, position the
cursor in front of the full stop and choose Edit, Paste Special. We select Paste Link and Unformatted Text:

© The Knowledge Base www.tkb.co.uk Page 39


When we click OK, the contents of the cell will be pasted into our document.

Again we can change the figure in Excel, and see the change in our Word document. Notice how we have
changed the font size and typeface in Word, updated our figure in Excel to 120, and, because we chose
‘Unformatted Text’ in the Paste Special screen the new figure is included in the chosen font:

2.4.1 Safety first


Whilst the links should work reliably, it would be a wise precaution to check that all figures and charts are as
you expect them to be before you march into an important meeting with your linked document!

Page 40 © The Knowledge Base www.tkb.co.uk


3. Miscellaneous
3.1 Protecting Excel spreadsheets
3.1.1 To be sure, to be sure, to be sure
First a little background on protection. Before launching into protection itself, it is crucial to ensure that no cell
anywhere on your worksheet is allowed to contain a mixture of data and formula. To help ensure reliability
we need to protect every cell that contains a formula, since allowing even a single formula to be changed
could compromise the integrity of the entire workbook. If every cell containing a formula is protected, and
therefore inaccessible, it follows that we can't include any data in formula cells, because if we did so, our
users wouldn't be able to access the data to change it. So, having separated all our data and formulae, we
can start turning protection on. This is a three stage process:

3.1.1.1 Stage 1: unlock the data cells


Given that you've been happily editing the cells in your sheet, it may come as a surprise to find that they are
all locked. Going to Format, Cells (Home ribbon, Font group, Font dialog) and then clicking on the
'Protection' tab will confirm that this is the case:

But this screen also explains why we can edit locked cells: locking doesn't take effect until we protect our
worksheet. Consequently, the first stage of setting up protection is to unlock the data cells. It's also a good
idea to change the background colour of the data cells to help users understand what they can change and
what is locked.

3.1.1.2 Stage 2: protect the sheet


Having unlocked all our data cells, we can now turn on sheet protection. Choosing Tools, Protection, Protect
Sheet (Review ribbon, Changes group, Protect Sheet) brings up the following screen:

© The Knowledge Base www.tkb.co.uk Page 41


If you use Excel 2000 or earlier, you will see a much simpler protection screen. Excel XP onwards made
protection a great deal more flexible and therefore useable by adding a set of tasks that you could allow
users to perform. Prior to this, protecting a sheet meant you could do almost nothing apart from editing
unprotected cells. Obviously, you will need to assess how your spreadsheet will be used and ensure that
allowing access to particular functions will not compromise its integrity. Whilst a password is useful for
stopping accidental changes being made, the Excel protection passwords should not be relied upon.
This protects our current sheet, but we would then need to repeat the process individually for all the other
sheets in the workbook.

3.1.1.3 Stage 3: protect the workbook


We've unlocked our data cells and protected every sheet in the workbook – surely that's it? Well, no it isn't.
Perhaps surprisingly, we could still delete an entire sheet, even if it contained protected cells. Therefore to
complete our protection process we need to use the Tools, Protection, Protect Workbook (Review ribbon,
Changes group, Protect Workbook, Protect Structure and Windows) option to protect the structure of the
workbook:

3.1.2 But…
We used to think that was it. Setting up protection in this way certainly prevents many of the problems that
users can inflict on your spreadsheet, however, as became apparent recently, not all. How do you stop users
cutting and pasting between unlocked data cells? The effect of this is to potentially mess up the references
to the data cells affected even in the protected cells. Of course it would be possible to write VB code to
prevent this, or to use form fields or some other method of data entry, but is there a simpler way? As we
have seen, in Excel XP and later, the protection capabilities have been substantially enhanced and allow
choice as to what a user can and cannot do. In addition, there is the ability to 'Allow users to edit ranges'.

3.1.3 Allow users to edit ranges


This option on the Tools, Protection ((Review ribbon, Changes group, Allow Users to Edit Ranges) menu
allows you to define cells and ranges of cells that particular users are allowed to edit – even if they are
locked:

To allow users to edit certain locked cells, click on the 'New' button. This lets you enter a title for each
range/permissions set, and define the cells that it refers to. Here we have entered a title of 'DataRange' and
selected cells A1 and C1.

Page 42 © The Knowledge Base www.tkb.co.uk


You can enter a password, but if the intention is to use this method as an alternative way of providing any
user with access to the data cells only, then you probably don't need to use a password. You can also use
this feature to set up much more complex permissions settings. Clicking on the 'Permissions' button will allow
you to select users or groups of users and allow or deny them the right to edit the range without a password.

3.1.3.1 Alternative protection


Using this method, there would be no need to unlock any cells. All cells, including the data cells would be left
locked. Before choosing to protect the individual sheets, the 'Allow users to edit ranges' option would be
used, without a password, to provide access to the data cells only. The sheet can then be protected directly
from the 'Allow users to edit ranges' screen, or via Tools, Protection. From then on, the protection procedure
is the same as for the standard method – protect all individual sheets, and then protect the workbook
structure.
The difference in the way the protected workbook behaves is subtle but crucial. You can type data into the
data cells as you could if they had been left unlocked, you can even copy and paste between data cells.
However, as we have seen, standard protection allows you to 'cut' the contents of a data cell. If you try to do
this when you have left all the cells locked and used the 'edit ranges' method you will see the following 'read
only' message:

3.2 Data validation lists


3.2.1 Introduction
Whilst the following technique is useful, whenever you find yourself entering data in Excel, it's always worth
asking yourself whether you might not be better using a database with all its built in data validation and data
control options.

3.2.2 Managing multiple lists


Data Validation includes the ability to enter items from simple lists via an in-cell dropdown. This is an
advanced application of this technique to cope with multiple lists.
Rather than littering the list source cells in some remote corner of the sheet, it seemed to make sense to
include them at the top of each column as in the following simplified example:

© The Knowledge Base www.tkb.co.uk Page 43


Setting up the data validation for each cell in each column is then relatively straightforward. Choose Data,
Validation (Data ribbon, Data Tools group, Data Validation) from the menu bar. Set the 'Allow' box to 'List',
then click in the 'Source' box and drag across the relevant list cells in the rows above:

3.2.3 Copying data validation settings


Having set up the data validation for cell B11, we can then copy this to whichever other cells we need to use
the same list. In this case this will mean copying it down the column to as many rows as we require.
If we now look at the data validation we need for the next three columns, we can see that in each case we
need to use a list of three items in rows 2 to 4. We could of course set the data validation up individually for
C11, D11 and E11 and then copy down the columns in the same way. However, we could adapt the 'Source'
entry slightly for C11 to make the column references relative rather than absolute:

Page 44 © The Knowledge Base www.tkb.co.uk


We have deleted the '$' in front of both references to column C to give us the range:
=C$2:C$4
Because the column references are now relative, we can copy C11 to D11 and E11 and the column
references will automatically change to refer to the new columns. It is important that we leave the row
references as absolutes (i.e. with the dollar signs in front of them) otherwise we will not be able to copy them
down the columns to the other rows without changing the reference to the list source.
So, in the screen shown below, we have selected cells B11 to E11 and then copied the cells by clicking on
the fill handle in the bottom right corner and dragging it down to row 13:

We should now find that we can click in any of the cells in the block, and the dropdown list will include the
items from the options section at the top of that column:

3.2.4 Apply changes to all other cells


Note that where you are working with groups of cells that have the same data validation settings, you can
edit them all by editing the validation settings for any one of them.
Click on one of the cells and choose Data, Validation (Data ribbon, Data Tools group, Data Validation). You
will notice that the dialog box includes an option to: 'Apply these changes to all other cells with the same
settings'. If you choose this option all the affected cells will be highlighted as we can see in the screen below.
Changing any of the data validation settings will then apply to all the cells highlighted:

© The Knowledge Base www.tkb.co.uk Page 45


You could of course hide the rows containing the options once you have finished setting data validation for
all the required cells.

3.2.5 Dynamic lists


It is quite easy to extend his method to enable the list in one cell to change depending on, for example, the
answer to a previous question. Just for a little light relief, we'll use this to create an Excel based 'Charades'
system.
We have set up a sheet that includes lists of films, books and television programs. To the left of these lists,
we have included some 'lookup' formulae to include the items from our selected list. We have two cells that
contain data validation lists. One will choose the category, and the second should then list the items in that
category:

First of all, we'll look at the data validation settings for cells K11 and K12.
In K11 we want to list our category headings from cells M4 to O4. In order to keep the structure as flexible as
possible, we will set up some range names so that we can add additional information without needing to
change the formulae used in our data validation settings. We will set up three names. M4 to O4 will be
named 'Categories', L5 to L8 will be 'Titles' and finally M4 to O8 will be 'Options'.

Page 46 © The Knowledge Base www.tkb.co.uk


Our data validation 'Source' can be set to '=Categories'. Note the use of '=' before the name.
In K12 we will include the items from the 'Titles' section. Again we will use one of our names:

So far it's all been relatively straightforward, but now we need to construct a rather more complicated set of
formulae to ensure that our 'Titles' range displays the set of options that correspond to the 'Category' that we
choose in K11.
We will need to use the 'HLOOKUP' function to lookup the individual items in the 'Options' area by comparing
the value in K11 to the value in the top row of the 'Options' range. So if we select 'Films' in the dropdown list,
we want our function to find the column headed 'Films' and show the value from each row in turn. We also
want to construct the function arguments so that we can copy it down from L5 to L8. To do this, we will need
to make the 'Row_index_num' argument include a number that is 'relative' to the position of the formula cell.
Let's look at the formula in the Insert Function screen:

© The Knowledge Base www.tkb.co.uk Page 47


3.2.5.1 Lookup_Value
$K$11
This needs to be an absolute reference to cell K11 so that when we copy the formula down, it still refers to
the same cell.

3.2.5.2 Table_array
Options
A straightforward reference to the 'Options' range – in this case no "=" is necessary.

3.2.5.3 Row_index_num
ROW(L5)-3
This is the complicated bit. The 'Row_index_num field needs a number that indicates how many rows down
the range we need to look to return our value. 1 would return the top row containing the category name. For
cell L5 we need the value 2, which corresponds to the same row as L5. If we just entered the number 2, then
we would have to change this to 3,4 and 5 for the other cells in the range. To save having to do this, we will
instead embed another function – the 'ROW' function.
'ROW' returns the row number of the cell used as the argument. So ROW(L5) will return 5. 5-3=2 which is
the answer we need. Of course, because the reference to L5 is relative, as we copy the formula down the
column, the argument will return the reference to the correct row each time. Here is an example of our
charades spreadsheet in action:

Page 48 © The Knowledge Base www.tkb.co.uk


3.3 Data validation formulae
3.3.1 Introduction
While we're on the subject of using formulae rather than just values, one of our clients asked whether Data
Validation could be used to control the format of mixed alpha-numeric code, such as an NI number or an
accounts nominal code.
In general, if you were trying to control the input of large amounts of structured data, we'd suggest that you
investigate using a database rather than a spreadsheet. As an example, MS Access provides built-in control
of data types and 'input masks' to control the format of text and other fields.
However, we will look at setting up a relatively simple Data Validation formula to control a short text code
input.

3.3.2 Accounts code


Let's imagine that we are entering some sort of accounts code that needs to be entered as a letter and then
three numbers:
A123
We'll start with the basics. First of all, we'll make sure that the user enters the right number of characters: 4.
From the 'Allow' drop down of the Data Validation screen, select the 'Custom' option. This will allow us to
enter a formula:

We are adding the data validation to cell A1, so we will set the formula as:
=LEN(A1)=4
As you can see, this formula must return a True or False. If True the value entered will be accepted, if False
the Error Alert will be triggered.

© The Knowledge Base www.tkb.co.uk Page 49


3.3.3 Letters v. Numbers
3.3.3.1 Numbers
We can use one of the Excel information functions – ISNUMBER() - to check whether a string contains just
numbers.
=ISNUMBER(VALUE(RIGHT(A1,3)))
For the first or last characters in a string we can use LEFT() or RIGHT(). If we needed characters from the
middle of the string we would use MID() which lets us set a starting position and number of characters. We
then need to convert the string to numbers. If all the characters are numbers this will be successful and
ISNUMBER() will return true; if any of them are letters VALUE() will return an error so ISNUMBER() will be
false.

3.3.3.2 Letters
Letters are not quite so easy to deal with. The ISTEXT() function looks quite tempting and will successfully
identify a whole cell as containing text rather than a number, but will not work with parts of a string. Using
LEFT(), RIGHT() or MID() returns text, even if the characters are numbers. VALUE() has to be used to
convert number characters to 'actual' numbers, but if we use VALUE() on a letter character we get an error
message which ISTEXT() reports as false.
One possible answer is simply to reverse the effect of ISNUMBER() by using it with the logical function:
NOT():
=NOT(ISNUMBER(VALUE((LEFT(A1,1)))))
Although this formula would successfully reject numbers, it would accept any characters apart from numbers
– such as brackets or other symbols.
It is possible to set up a very specific data validation formula using Excel's ability to convert a character to a
code number – the CODE() function. This number could then be compared with the required range of codes.
For example, A is ASCII character 65, and Z is 90. To find out the ASCII code of a character, you can use
the CODE() function to return the value of the first character in a cell:

You could use the following formula to check whether the entered value is an uppercase letter:
=AND(CODE(LEFT(A1,1))>=65,CODE(LEFT(A1,1))<=90)
This formula uses AND() to make sure that several separate criteria all have to be met.
The problem with this formula is that it gets prohibitively long with more than two characters. The Data
Validation formula editor makes it very difficult to work with formulae of more than about 60 characters.

3.3.4 AND()
Having established the three criteria that must be met:
• The length of the value entered
• Whether the last three characters are numbers
• Whether the first character is an uppercase letter
We need to add them together within the AND() function to create the following rather complex formula:
=AND(CODE(LEFT(A1,1))>=65,CODE(LEFT(A1,1))<=90,LEN(A1)=4,ISNUMBER(VALUE((RIGHT(A1,3)))))
If you actually try and enter this in the Data Validation formula box, you will run out of room:

Page 50 © The Knowledge Base www.tkb.co.uk


even pressing the expand/collapse button doesn't help a great deal:

The real problem occurs if we make a mistake and try and use the cursor keys to go back – this is
interpreted as inserting a cell reference, so getting to any part of the formula that is not displayed can be a bit
of a struggle.
It is much easier to enter the formula in a normal Excel cell. This will also give you the ability to check the
result with all the available permutations. If the formula returns TRUE then a similar data validation formula
will accept the entry. You can then refer to that cell via the data validation formula. Better still, name the cell
something like 'InputCheck' and then refer to the name in the validation formula:

3.3.5 But
This method will only work if we are dealing with a single input cell. Because the formula refers to a particular
cell, if we try and copy the data validation to another cell it will not validate that cell, but instead look at the
contents of the original cell. If we needed to validate a group of cells, we could include the formula next to
each cell, perhaps in a hidden column. Then we would need to select the cells to be validated and set our
Custom formula to look at the first of the cells as a relative formula. This would then set each cell to look to
the cell immediately to its right for the validation formula:

© The Knowledge Base www.tkb.co.uk Page 51


As you can see, there is a good reason for hiding column B, and when you attempt to accept your validation
formula you will be warned that the formula currently evaluates to an error. However, you should find that the
validation works correctly as data is entered.

3.3.6 More columns


Our final formula in cell B1 is as follows:
=AND(CODE(LEFT(A1,1))>=65,CODE(LEFT(A1,1))<=90,LEN(A1)=4,ISNUMBER(VALUE((RIGHT(A1,3)))))
This is not the easiest formula to understand. There is a lot to be said for breaking it up into its separate
sections and placing each in its own cell. The AND() function could then be used to create the overall
formula:
B1: =CODE(LEFT(A1,1))>=65
C1: =CODE(LEFT(A1,1))<=90
D1: =LEN(A1)=4
E1: =ISNUMBER(VALUE(RIGHT(A1,3)))
F1: =AND(B1:E1)
If we give the columns headings, and leave them unhidden, we can see in more detail why particular entries
are rejected:

In fact, we could go even further and use the column headings to hold the values that the conditions are
based upon, making it easier to change those conditions. Because of the individual cell approach, it would
also be easy to insert an additional column to extend the validation criteria. Here we have inserted a new
column E that checks that the number portion is not 000. Note the use of the ISERROR() function to return
FALSE if there is a letter in the 3 number positions, rather than a #VALUE error message:
Page 52 © The Knowledge Base www.tkb.co.uk
E2: =IF(ISERROR(VALUE(RIGHT(A2,3))),FALSE,(VALUE((RIGHT(A2,3))))>0)

3.4 Paste special


If you choose ‘Paste Special’ from the ‘Edit’ (Home ribbon, Clipboard group, Paste dropdown) menu instead
of the normal ‘Paste’ you will see the following menu (a few of the options in the ‘Paste’ section are only
available with later versions of Excel, so you might not see all of the ones here):

The default option ‘All’ is the same as a normal paste. Here is a brief description of the other available
options:

3.4.1 Formulas
Pastes text, numbers and formulas, but not the formatting of the cells, this will remain the same as the
formatting of the destination cells. It is therefore pretty much the opposite of ‘Formats’ below:

3.4.2 Values
Converts any formulas to the results of those formulas thus ‘fixing’ the values as they were at the time the
operation was carried out. You can use this to convert an area from formulas to values by copying it and then
pasting it as ‘Values’ to the same location.

3.4.3 Formats
As mentioned for ‘Formulas’, ‘Formats’ and ‘Formulas’ are a matching pair. ‘Formats’ pastes just the formats
of the copied cells, not the contents.

3.4.4 Comments
Just pastes the comments from the selected cell, or any comments from a selected block of cells.
© The Knowledge Base www.tkb.co.uk Page 53
3.4.5 Validation
Pastes any input validation settings as set up via ‘Data’, ‘Validation’ from the selected range.

3.4.6 All except borders


Same as a normal paste but any borders on the copied cells are not pasted to the destination.

3.4.7 Column widths


Just sets the column widths of the destination cells to the same column widths as the columns containing the
selected cells.

3.4.8 Formulas and number formats


Pastes as for ‘Formulas’ but also pastes any number formatting from the selected cells.

3.4.9 Values and number formats


Pastes as for ‘Values’ but also pastes any number formatting from the selected cells.

3.4.10 Operations
These allow you to select a cell, or a range of cells, and then paste it to one or more destination cells.
Depending on the operation chosen, the destination cells will be added to, subtracted from, or multiplied or
divided by, the source cells. For values, this will change the values. For formulas, it will add the appropriate
operation to the end of the formula.
You can select cells with values or cells with formulas in them to form the basis for the paste special
operation.

3.4.11 Skip blanks


Allows you to avoid overwriting destination cells if the corresponding source cell is blank.

3.4.12 Transpose
This is a very useful one, and best explained by a demonstration. Here we have some dates:

Now we decide that we want them as column headings, rather than row headings. So we select them and
choose ‘Copy’:

Page 54 © The Knowledge Base www.tkb.co.uk


We select cell ‘B1’ and choose Edit, Paste Special and select Transpose:

3.4.13 Paste Link


Finally, the ‘Paste Link’ button creates a reference to the copied cells in the destination cells.

3.5 Pivot Table grouping


3.5.1 It’s about time
Pivot Tables are excellent for summarising data. Sometimes you will just want to summarise by the field
itself, as in the example of Salespersons below, but other fields need to be 'grouped' in some way. Our
example is based on a set of invoice fields, linked to the 'Northwind' database provided as a sample with
Microsoft Access. We will be adding the OrderDate field as a column heading. To do this just drag it from the
PivotTable Field list and place it over the word ‘Total’:

© The Knowledge Base www.tkb.co.uk Page 55


You should see a warning you that the table can no longer fit (because there are over 250 or so individual
order dates), and asking whether you just want to display as much as possible. Answer ‘Yes’.

Seeing a column for every single day is probably not very helpful. What we need to do is to group the dates
together into months and possibly years. Again it is the right click to the rescue. Right click on any date and
from the shortcut menu choose ‘Group and Outline’, Group (Group). You can now select one or more
grouping periods – from minutes to years! We will leave the default of ‘Months’ selected, but also click on
‘Years’:

This groups our OrderDate field by month, and adds an additional Years field:
Page 56 © The Knowledge Base www.tkb.co.uk
We will drag the Years field to the Page area, above the Sum of ExtendedPrice field. We can now choose to
look at just one year by selecting it from the drop down list. We will choose the most recent year – 1998, and
here is our PivotTable showing a summary of sales by salesperson by month.

3.5.2 Manual grouping


You can also set up your own groups by selecting some items from a particular field, right clicking and
choosing 'Group' as before. Here is an example with our salespersons. We select Andrew Fuller, Anne
Dodsworth and Janet Leverling; right click on any one and choose to group them. This creates a new field
called 'Salesperson2' with a group shown as 'Group1' below:

We can click in our headings and rename the new fields and groups to make them more useful, and allocate
our other salespersons to appropriate groups:

© The Knowledge Base www.tkb.co.uk Page 57


4. Charts
4.1 Graph on two axes
In this section we will look briefly at creating a graph in Excel that compares two types of information in
different units – for example sales of bananas in tons compared to net profit in £’000.

Sales Net profit


tons £'000
January 2,598 15,500
February 3,450 18,900
March 6,702 23,950
Here is a line chart based on the data:

40,000
20,000 Sales
tons
-
January February March

If we double click (Right click, Format Data Series) the ‘Sales tons’ line we will see the format data series
dialog. We can then choose the axis tab (Series Options), and select to plot the sales in tons against a
Secondary axis:

and here is the revised graph showing appropriate axes for both £’000 and tons:

30,000 8,000
25,000 Net profit
6,000
20,000 £'000
15,000 4,000
10,000 Sales
2,000 tons
5,000
0 -
January February March

Page 58 © The Knowledge Base www.tkb.co.uk


4.2 The ever changing lights of Balham
4.2.1 Introduction
Thanks are due to Microsoft MVP Bob Phillips for the inspiration for this bit. Bob ran a session at the Excel
User Conference 2007 which dealt with improving the visual impact of your Excel spreadsheets. One idea
was to condense graphics into a single cell and Bob demonstrated how to use conditional formatting to
create 'traffic lights'.
Conditional formatting is one of my favourite features in Excel – mainly because it means I can compare it to
Zaphod Beeblebrox's peril sensitive sunglasses. Although Excel 2007 greatly extends the capabilities of
conditional formatting, allowing you to include colours, scales and icons, most users are still stuck with the
much more basic three conditions in earlier versions of Excel. However Bob's method just needs those three
conditions.
The idea is to use conditional formatting to add the 'traffic lights' next to a column of figures, rather than
colouring the cells containing the figures themselves.

This involves the use of the slightly more complicated 'Formula is' rather than 'Cell value is' variation of
conditional formatting and a bit of lateral thinking.

4.2.2 Setting up the conditional format


The upper and lower limits have been entered into cells E1 and E2 respectively and these two cells have
been given the names 'Top' and 'Bottom' to make it easier to refer to them via our conditional formatting
formula.
First of all, select the cells to the right of the figures – in this case B1 to B8. Then go to Format, Conditional
Formatting:

Change the type of condition to 'Formula is' and then enter the condition as: =A1>Top.
Because the active cell is B1 and we have entered the formula as =A1 (don't forget the equals sign), the
format will apply 'relatively' to the cell to the right of each individual figure.
We have set the format for the first condition to a Font colour or red:

© The Knowledge Base www.tkb.co.uk Page 59


and a Pattern of solid black:

We have also set up a white outline border:

We then need to set up the formats for 'amber' and for green.

Page 60 © The Knowledge Base www.tkb.co.uk


The condition for amber is set to: =A1>Bottom (the first condition =A1>Top will take precedence for items
that are greater than Bottom and Top).

The format is set in the same way as for the first condition, but with the font colour set to 'gold'.
Green is set to: =A1<=Bottom with the font colour set to green:

Now for the lights themselves. In cell B1 we can use Insert, Symbol to insert a shape from the 'WingDings'
front and then increase the font size to an appropriate value:

This can then be copied down to the rest of the cells in the range.

4.3 30 second graph in a cell


4.3.1 Using the REPT() function
Another idea for the single cell graphic covered in the same Excel User Conference session was the use of
the REPT() function to create 'in cell' bar charts.
The idea here is to repeat a particular character a number of times that depends on the value of the
adjacent(ish) cell.
We'll set up an example in column C of our existing sheet.
The basic formula is something like:
=REPT("I",A1/50)
© The Knowledge Base www.tkb.co.uk Page 61
This repeats the capital I character by the value of A1 divided by 50. We divide by 50 to reduce the number
of characters to fit in a column of reasonable width.

4.3.2 Automatic scaling


The problem with dividing by a fixed figure is that, if the value in A1 increases substantially, then the row of
I's may no longer fit in the column.
One solution would be to make the scaling dynamic. Instead of a fixed figure, we could calculate the figure
by starting with the largest number in the column, and working out the maximum number of I's that would fit
in the column. The following formula is not perfect – it might be better to name our range of cells and refer to
the name rather than an absolute reference:
=REPT("I",A1/(MAX($A$1:$A$8)/20))
We have used the MAX() function to find the largest number in the range, and then divided it by 20, this
should ensure that the column of I's is limited to a maximum of 20. If the largest number increases, then all
the bars will be dynamically scaled accordingly:

4.3.3 REPT() and conditional formatting


We could combine our conditional formatting technique with our repeating bars. Here we have used similar
'Formula is' conditions to our traffic light example, and have set the font colour as red, gold and green as
before. We have not set a border or a pattern:

If we change the value in A1 to 4,000 thus changing the maximum and thereby our 'scaling' factor, the bars
should adjust dynamically as shown below:

Page 62 © The Knowledge Base www.tkb.co.uk


4.4 Pictures as fill effects
Throughout the Office suite, you can choose to ‘fill’ the background of objects with a series of effects such as
gradients, textures and patterns. It is the fourth option – pictures – that we will deal with here.
Each area of a graph is a separate object, and as such each can have a ‘fill’. This applies to bars, columns
and pie slices for example. In this case we are going to replace our coloured bars for Apples, Oranges and
Bananas with appropriate pictures.

We will change Apples to apples first. So we double click (Right click, Format Data Series) on the Apples bar
and the Format Data Series dialog box appears. This has several tabs, but it is the first, ‘Patterns’ tab that we
need (Fill option, Solid fill, Colour):

© The Knowledge Base www.tkb.co.uk Page 63


As you can see from the above screen, you can change either the border or the area of the Data Series. We
will change the area. Currently a colour is allocated automatically – we could choose a specific colour if we
wished. Note also that we could click on the ‘Invert if negative’ option – if one of the elements of the series
were to be negative, then the colour would change to the foreground colour. However we want more than
just a colour, so we click the Fill Effects button (Gradient fill/Picture or texture fill):

The Fill Effects dialog has four tabs, allowing you to set gradients, textures, patterns (although in most cases
patterns are probably best avoided) and the option that we are going to choose, Pictures (Picture or texture
fill):

Page 64 © The Knowledge Base www.tkb.co.uk


We click the Select Picture (File, Clipboard or Clip Art) button. This is probably the most difficult bit – we will
need to scour our computer to find an appropriate picture. You may find it helpful to use the clip art catalogue
search to locate a suitable picture, then right click it to view its properties – that should show you the file
name. We have found a picture of an apple from the Office clip art.

If we look at the Format options at the bottom left hand corner of the screen we can see that we are currently
‘stretching’ the picture to fill the bar, the chart will look like this:

Maybe slightly more interesting, but not of much help in showing how many apples we have sold. If we go
back to our Fill Effects, Picture screen, we can change the format to ‘Stack and scale to:’ a certain number of
units – e.g. one apple represents £10,000 of apple sales:

© The Knowledge Base www.tkb.co.uk Page 65


We can then repeat the exercise for Oranges and Bananas, being careful to keep the units to pictures ratio
consistent, and of course using appropriate pictures:

If you look very carefully, you will see that even the legend keys have been changed to the pictures that we
have chosen.
Fill effects can be applied to the background of many objects, including the whole chart area, the legend and
the plot area.

Page 66 © The Knowledge Base www.tkb.co.uk

You might also like