Categories
Notes Old site

Dynamic Ranges

Usually, when you specify a range in a formula, you specify it through its address: for example, $B$5:$C$10. However, you can specify ranges through formulae, effectively making them dynamic.

There are a number of formulae you can use to specify dynamic ranges, including OFFSET and IF.

Using the OFFSET formula to define a dynamic range

The formula that is most often used to define a dynamic range is OFFSET. The result of an OFFSET formula is a range. You have to specify the top left hand corner and the dimensions.

Specifically, there are five arguments:

  • Reference: A range that forms the basis of the new range. This can be a single cell, or a range of adjacent cells.
  • Rows: The number of rows up (negative) or down (positive) from the top of the reference range that you want the new range to start at.
  • Cols: The number of columns left (negative) or right (positive) from the left of the reference range that you want the new range to start at.
  • Height: The height (number of rows) of the new range. This argument is optional. If you omit it, the new range will have the same number of rows as the reference range.
  • Width: The width (number of colums) of the new range. This argument is optional. If you omit it, the new range will have the same number of columns as the reference range.

So, for example, the result of the formula OFFSET($B$5:$C$10, 3, -1) would be the range A8:B13: it starts 3 rows down and one column to the left of B5, and has 6 rows and 2 columns, just like the range $B$5:$C$10.

The real utility of this formula comes when you use formulae for some of the arguments, and define a name to refer to it.

For example, suppose you have monthly sales data in a spreadsheet; you want to plot a chart, but don’t want to edit the chart each time you update the sales data.

sales data in column B

You can define a name SalesData to refer to the following formula:
=OFFSET(chartData!$B$5,0,0,COUNT(chartData!C:C)-COUNT(chartData!$B$1:$B$4),1)
and then set the data series in the chart to refer to SalesData.

You can then update the chart simply by adding a new line of data.

Note that we have to be a bit careful how we specify the number of rows in the dynamic range, so as not to count any values that are not sales data.

Using IF to define a dynamic range

There is an even simpler way to define a dynamic range, which is especially useful for data validation. Suppose you have related sets of options: if you choose a service level of premier, for example, you can choose one of three delivery methods, but if the service level is standard, you only have a choice of two.

sales data in column B

For the cell B5 we can set the data validation type to list and enter the following formula as the range:
=IF($B$4="Premier", $E$3:$E$5,$E$4:$E$5)
The drop down box for cell B5 will then show the valid delivery options for the service level chosen in cell B4.

Categories
Notes Old site

Operational Risk

Operational risk is gaining an increasingly high profile. In the UK, the Turnbull report recommended that listed companies should manage their operational risk explicitly; and the FSA includes operational risk in its new ARROW framework for risk assessment.

Historically (though the history is admittedly rather short), operational risk has received most attention from the banking industry. This is still evident in much of the published literature; often the authors simply assume that the industry in question is banking, without explicitly saying so. This can be confusing.

Definition

The FSA, following Basel, defines operational risk:

Operational risk is the risk of loss, resulting from inadequate or failed internal processes, people and systems or from external events.

This definition gives a reasonable idea of operational risk, but is not detailed enough for operational use. For purposes of risk identification, assessment, control and mitigation the definition must be refined so that it is a clearcut decision as to which risks are included and which are not.

In addition, the final phrase or from external events must be interpreted appropriately for the organization in question. For example, for a general insurance company the losses due to paying out claims for an earthquake should not be counted as an operational loss, whereas the losses due to the destruction of head office by the same earthquake should.

Resources

The following external links are relevant:

Categories
Notes Old site

Software Risk

Software risk is a form of operational risk: it consists of the risks of using software.

The principal components are:

  • Erroneous results. The software produces the wrong results.
  • No results. The software fails to produce results, or fails to produce them by the time at which they are needed.
  • High costs. The results are accurate, and appear on time, but at a very high cost.

These risks apply whether the software is developed in-house or externally and whether by professional developers or users (see user-developed software. Problems can be caused by:

  • Bugs
  • Usability issues
  • Development delays
  • Misunderstood requirements

among other causes.

Resources

The following external links are relevant:

Categories
Notes Old site

Using Names in charts

There are some ways of using Excel names in charts that can help make your charts easier to set up and maintain. You can use names to define the data series; in conjunction with dynamic ranges, you can then build dynamic charts without the use of macros.

Using names in charts

You can use a name in most of the places that you can use a range, when setting up a chart. However, you must always prefix the name with the worksheet or workbook name and an exclamation mark.

In particular, you can use names when specifying data series.

Chart data series

If you are using a name with workbook visibility (ie not local to a worksheet), you can prefix the name with either the workbook name or the sheet name when you type it in. Excel will automatically change the prefix to the workbook name. If you are using a name that is local to a worksheet, you must prefix the name with the worksheet name.

The useful thing about using a name to specify a data series is that if you change the range the name refers to, the chart will automatically show the new data. You don’t have to edit the chart in any way. As editing charts can be fiddly, this can be very helpful.

You cannot use names when specifying a data range. If you type a name in, Excel will automatically change it to the absolute address.

Chart data range

Categories
Notes Old site

Modularity

Modular systems are usually easier to maintain and update, as well as being faster to develop in the first place. So what is modularity?

A modular system is one that consists of a number of small, coherent, chunks (or modules) each of which is self-contained and has a well-defined interface.

Modularity is the single attribute of software that allows a program to be intellectually manageable.
G Myers, 1978

Modularity helps to reduce complexity. A modular system can be understood in terms of the individual modules, without having to grasp all the details at once. Modularity thus provides abstraction.

If the module boundaries are drawn appropriately, modifications to the system are often confined to one or two modules, thus simplifying the modification process.

Another advantage of modularity is that it facilitates code reuse. Again, if the modules are well defined, a single module can be used in several different systems, thus reducing the need to reinvent the wheel.

Categories
Notes Old site

Abstraction

The notion of abstraction is extremely important for writing good programs or designing good systems. Basically, the idea is that you want to avoid getting hung up on the details: you want to separate the things that change from those that
don’t
.

In Excel spreadsheets the easiest example of abstraction is the use of names. You can define a name to refer to a particular range: for example, you could define VATrate to refer to cell D3 on sheet TaxCalcs. By using a name for this, you have abstracted away two levels of detail:

  • The actual VAT rate to use; instead you use the value in cell D3 on sheet TaxCalcs.
  • The actual cell that contains the value; instead you use the name VATrate.

Using abstraction usually has advantages for maintainability, and we can see several of them in this example.

  1. A formula that reads =B26*(1+VATrate) is much easier to understand than either =B26*(1+$D$3) or =B26*1.175
  2. If you want to change the rate of VAT that you are assuming, it is much easier to change the value of a single cell than it is to go through all the formulae in the workbook looking for places where 17.5% is used, and changing them all individually.
  3. If you want to change the layout of your sheet, it is much easier to change the definition of the name VATrate than it is to change all references to cell D3, or to make sure that you drag and drop the cell or cut and paste it in such as way as to preserve all the references.

There are other ways of making use of the advantages of abstraction, but the use of names is the most common in Excel.

Categories
Notes Old site

Defining Names

In Excel, you can give a range a name. You can do this in two ways, using the Name Box or by using the Define Name dialog. You can change the range that a name refers to, or delete a name, using the Define Name dialog.

Using the Name Box is quicker and easier for straightforward name definitions, but the Define Name dialog provides a more flexible interface.

Using the Name Box to define names

Picture of Name Box

Select the range that you wish to give a name to, and type the name into the Name Box, which is the box just above the top left of the spreadsheet area. In the example, we are defining the name Total to refer to the single cell
A2. Multi-celled ranges canbe given names in exactly the same way.

The Name Box shows all the names that are currently defined, through the drop-down just to its right. Select any name in the drop down to select that range in the workbook.

If you happen to select a range that has a name defined for it, the name will appear in the Name Box.

Using the Define Name dialog to define names

Open the Define Name dialog from the menu, using Insert\Name\Define... Type the name that you wish to define in the top box (Excel will often suggest one for you) and then use the Refers to box to enter the range. You can type the range in, or select it in the usual way. If you type it in, make sure it is an absolute range (with dollar signs) unless you know what you are doing (see related note on using names for formulae). Finally, use the Add button to add the new name to the list.

To delete a name, select it in the list and use the Delete button.

To change the definition of an existing name, select it in the list and change its definition in the Refers To box, then use the Add button.

Categories
Notes Old site

Names can be local to worksheets

Many names in Excel are global in scope: the same name means the same thing wherever it is used. For example, the name
Inflation might refer to cell B2 on worksheet Costs.

Often, though, you may have many similar sheets; for example, an Costs sheet for each year of a 5 year business plan. In such cases you might want to use a different inflation rate for each year, but you would still want to use a named range. The solution is to use a name that is local to the worksheet in question.

Names local to worksheets

You can define a name that is local to a specific worksheet by prefixing the name with the worksheet name followed by an exclamation mark. So, for example, you might define CostsYear1!Inflation to refer to B2 on sheet CostsYear1, CostsYear2!Inflation to refer to B2 on sheet CostsYear2, and so on.

If you use the name Inflation in a formula on sheet CostsYear1, it will refer to the value in cell B2 on that sheet. Similarly, the name Inflation when used in a formula on sheet CostsYear2 will refer to the value for year 2.

You can use a name that is local to a specific worksheet on another sheet by using the full name with the sheet prefix, for example CostsYear1!Inflation.

If you have a local and a global name with the same name, the global name is not visible on the worksheet in which the local name is defined.

The Define Name dialog shows only global names and those that are local to the currently active worksheet. Similarly, the Name Box also omits names that are local to other worksheets.

Categories
Notes Old site

Using Names for formulae

The usual way to use Names in Excel is to use them to refer to absolute ranges. Typically, the name VATRate might refer to the range $D$2, for example.

However, it is possible to define names to refer to formulae that use relative ranges.

Names that refer to formulae can be useful when they are used to define dynamic ranges. On the whole, however, they should be used with caution: make sure they are documented somewhere, so that a future maintainer will find it easy to understand what is going on. One source of confusion is that their definition may depend on the currently active cell.

Names for formulae

When you define a name using the Define Name dialog, you can actually type any formula you like in the Refers to box. The formula is interpreted as being relative to the currently active cell in the workbook.

For example, if you have cell B9 selected, so that it is currently active, you could define a name AboveAndLeft as referring to =B8+A9. You could then use this name in cell D12, say, to add the
values in D11 and C12.

Picture of formula name