Excel Tools & Techniques: September 2017

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

September 2017

Excel Tools & Techniques

Assumptions

It is assumed that students have already used Excel and are familiar with formulae,
functions, relative and absolute cell addressing and creating charts. Any student not
possessing this knowledge should undertake the Excel Precursor Tutorial available
on the Introductory Computing Course for MSc Students Learn site.

Manipulating and Working With Data

Data can be sorted into either ascending (A-Z, -999 - 999, 1/1/00-
31/12/99) or descending (Z-A, 999 - -999, 31/12/99-1/1/00) order.
Clicking on either of the sort buttons (shown right) under the Data
tab on the ribbon will sort on one column. By selecting Sort from the ribbon you can
increase the complexity of the sort by adding several Levels.

Pivot Tables

Sometimes a spreadsheet contains so much information that it is difficult to see what


it is that you want or need from the data. A pivot table is a way of organising and
summarising a set of data so that only the data that you wish to use is visible and
arranged in a way that makes the data easy to understand. To create a pivot table
select Insert Tables PivotTable from the ribbon. The steps for setting up a pivot
table are outlined below.

Note: In previous versions of Excel, pivot table creation was done through a Wizard.
This has now been deprecated in the current version and is replaced as outlined
below.

1. Select the data source and range for the data. This is most likely to be the Excel
spreadsheet you are working with (the default choice); although could, for
instance, be a database table. You can choose a subset of the data using the
Range box. Generally it is best to place it on a new worksheet unless both the
original data set and the pivot table are quite small and you want to change the
original data.

2. At the right hand side of the pivot table you will see the Field List. This is the key
to the whole concept of the pivot table. The Field List allows you to select data
fields to be the page, row and column headings of the new table. Click and drag
the fields you want from the list to the required position in the pivot table layout at
the bottom right.

Once a pivot table is set up it is very easy to rearrange ("pivot") the data into another
configuration. Fields that you no longer need can be dragged back up into the Field
List.

You can also filter out field values to show only those you need to see.
Looking up Values in a Table

Values in a table (not just a pivot table - any Excel data block can function as a table)
can be found using the HLOOKUP and VLOOKUP functions. HLOOKUP finds
values in columns, VLOOKUP finds values in rows. The format for both functions is
shown below.

=HLOOKUP(lookup-value, table-array, row-index, range-lookup)

=VLOOKUP(lookup-value, table-array, column-index, range-lookup)

lookup-value is the title of the column or row that you are looking in.

table-array is the range of cells (including the header row/column) that is


to be searched.

row/column-index is the number of the row or column from which the value is
returned. (Note: Column number, not reference letter!). This
need not be a fixed value - values can be calculated based
on an offset from a known first value.

range-lookup is an optional argument and can be set to TRUE or FALSE.


If TRUE, the values in the first row (HLOOKUP) or column
(VLOOKUP) must be placed in ascending order, i.e. ..., -2, -
1, 0, 1, 2, ... or A-Z, otherwise the function may not give the
correct value. If range-lookup is FALSE, the table-array does
not need to be sorted, but only exact matches of lookup-
value will be found. If TRUE, or omitted, then approximate
matches are acceptable and if no exact match to lookup-
value is found then the next nearest lower value is found
instead.

Example:

A B C D E F
1 UK France Germany Spain Italy
2 1999 500 376 865 675 342
3 2000 796 978 984 788 438
4 2001 876 348 734 788 623
5 2002 985 854 234 685 757
6 2003 658 986 974 976 365

=HLOOKUP("Spain",A1:F6,4) gives the answer 788 (for 2001).


=VLOOKUP(2002,A1:F6,3) gives the answer 854 (for France).
=HLOOKUP("Germany",A1:F6,2002-1999+2) gives the answer 234 (for 2002).

Using Excels Analysis Tools

Excel has a number of useful built in tools to speed up and simplify complex tasks.
You must first ensure that the Analysis Toolpack is enabled - see the separate notes
for how to do this.
Using the Linear Regression Analysis Tool

Linear least-squares regression can be quite a time-consuming task to undertake


manually and can be prone to error. With the Excel regression analysis tool, minutes
of work are done in seconds!

Select Data Analysis Data Analysis from the ribbon then select Regression
from the dialogue box that appears (you may need to scroll down to find it) and click
on OK. You now need to select the cell ranges for the x and y values by either typing
them in or clicking and dragging on the worksheet. When you click on OK, Excel will
automatically perform the regression and presents the results in tabular form on a
new worksheet. You will learn more about this important technique later on your
course, but for the moment the important values to pull out of the table are the
intercept and the gradient (referred to as X Variable 1). These are the two values at
the bottom left of the table.

SUMMARY OUTPUT

Regression Statistics
Multiple R 0.9238009
R Square 0.8534081
Adjusted R Square 0.8411921
Standard Error 6.509361
Observations 14

ANOVA
df SS MS F Significance F
Regression 1 2960.088313 2960.088 69.8599 2.39441E-06
Residual 12 508.4613649 42.37178
Total 13 3468.549678

Coefficients Standard Error t Stat P-value Lower 95% Upper 95%


Intercept 4.9372347 4.731260389 1.043535 0.317268 -5.37129599 15.24576533
X Variable 1 1.0082047 0.12062428 8.358223 2.39E-06 0.745386963 1.271022413

Solving Linear Programming Problems

Excel contains a linear programming/optimisation analysis tool called Goal Seek that
looks for the best possible ("optimal") solution to a given problem. You set an answer
cell (the target) and Excel will provide the best answer based on the numbers you
set and a constraint (for example that the answer must be a positive integer).

The first thing to do is to build the model that you wish to solve. You will need to
provide an approximate "best guess" answer to complete the model, but it doesn't
matter if this is way off the mark.

Once that is done, select Data Data Tools What-If


Analysis Goal Seek... from the ribbon to bring up the
Goal Seek dialogue box (shown right). You then need to
set three parameters:

1. The reference to a cell containing a constraint value. The cell must contain a
formula or function (Set cell box).

2. The value of the constraint that the cell is to converge to (To value box).

3. The reference to a cell to contain the solution. This cell must contain a value,
not a formula or function (By changing cell box).
Sensitivity Analysis

This is a technique, rather than a tool, which lets you see how changing one value in
an equation alters the result. Several copies of the equation or model are created
and a different value is given to one of the parameters in each instance. Usually, as
with linear programming, you start with a best guess for the parameter's value and
then add and/or subtract from that value to see how the result changes.

Statistical Tests

Sometimes you will want to check that the data you have is valid. This is usually
done by comparing it with a known set of benchmark data. Two particular tests are of
relevance: Chi-square and t-Test.

Chi-square Test

A chi-square test is used to determine if a set of observed results matches the


distribution of expected results. The total number of all results in both observations
must be the same. The closer the observed values are to the expected ones, the chi
squared value tends toward 1. As the chi squared value approaches zero, the less
match there is between the observed and expected values. The function is CHITEST
and it takes two cell ranges as arguments; the observed range and the expected
range respectively.

t-Test

A t-test is used to determine the similarity, or lack thereof (the variance), between the
means of two sets of normally distributed data. Select Data Data Analysis t-
Test: Paired Two Sample for Means from the ribbon. The two data ranges to be
compared are then selected and the Mean Difference set to be 0. You must also set
an Alpha value, which is the error probability threshold that you are prepared to
accept. This defaults to 0.05 (95% confidence); which is fine in most cases, but to
get a more accurate result can be set to 0.01 (99% confidence). The important
values to look for are the P(T<=t) values. If these are greater than your chosen Alpha
value, then the null hypothesis (that the distributions are similar) can be accepted.
The two-tailed value tests if the distributions are equal and the one-tailed value tests
if the second mean is bigger or smaller than the first.

t-Test: Paired Two Sample for Means

Variable 1 Variable 2
Mean 5.598171693 6.090785193
Variance 0.637024397 2.337461184
Observations 12 12
Pearson Correlation 0.100506038
Hypothesized Mean
Difference 0
df 11
t Stat -1.032949922
P(T<=t) one-tail 0.161901816
t Critical one-tail 1.795884814
P(T<=t) two-tail 0.323803633
t Critical two-tail 2.200985159
Monte Carlo Simulation

This is another technique used in numerical modelling. It creates a series of


stochastic (i.e. semi-random) values to model fluctuations in a system (e.g. share
prices). Random numbers can be generated using either the RAND function or with
the Random Number Generator analysis tool (Data Analysis Data Analysis
Random Number Generation).

RAND only ever produces a


number between 0 and 1. The
analysis tool allows more
flexibility: For example; you can
set the range (e.g. between -1
and 1), you can set the
distribution (e.g. Gaussian, rather
than linear).

Using Visual Basic Applets

A Visual Basic Applet is a small program that automates a complex repetitive task;
for instance incrementing a year value, then conducting a series of annual
calculations and presenting the result(s) before moving on to the next year, and so
on.

To enable the use of applets (sometimes called macros) in Excel a further tab (the
Developer tab) must be added to the ribbon:

Click on the File tab and select Options then Customize Ribbon (sic.). Find the
entry for Developer in the right-hand window and click in the checkbox then click on
OK.

A simple macro of a Monte Carlo model representing share price fluctuations is


provided.

Teaching Visual Basic is beyond the scope of this course. If you wish to learn more
there are ample teach yourself books (for instance Visual Basic for Dummies or
Using Excel VBA) available in most bookshops.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy