Excel 2007 Formulas (Mr. Spreadsheets Bookshelf)

 Download CD Content

When most people think of Excel, they think of analyzing rows and columns of numbers. As you probably know already, though, Excel is no slouch when it comes to presenting data visually in the form of a chart. In fact, it's a safe bet that Excel is the most commonly used software for creating charts.

After you've created a chart, you have almost complete control over nearly every aspect of each chart. This chapter, which assumes that you're familiar with Excel's charting feature, demonstrates some useful charting techniques-most of which involve formulas.

Understanding the SERIES Formula

You create charts from numbers that appear in a worksheet. You can enter these numbers directly, or you can derive them as the result of formulas.

Normally, the data used by a chart resides in a single worksheet, within one file, but that's not a strict requirement. A single chart can use data from any number of worksheets, or even from different workbooks.

A chart consists of one or more data series, and each data series appears as a line, column, bar, and so on. Each series in a chart has a SERIES formula. When you select a data series in a chart, Excel highlights the data with an outline, and its SERIES formula appears in the formula bar (see Figure 17-1).

Figure 17-1: The formula bar displays the SERIES formula for the selected data series in a chart.

Note 

A SERIES formula is not a "real" formula. In other words, you can't use it in a cell, and you can't use worksheet functions within the SERIES formula. You can, however, edit the arguments in the SERIES formula to change the data that's used by the chart.You can also drag the outlines in the worksheet to change the chart's data.

A SERIES formula has the following syntax:

=SERIES(series_name, category_labels, values, order, sizes)

The arguments you can use in the SERIES formula include

Range references in a SERIES formula are always absolute, and they always include the sheet name. For example

=SERIES(Sheet1!$B$1,,Sheet1!$B$2:$B$7,1)

A range reference can consist of a noncontiguous range. If so, each range is separated by a comma, and the argument is enclosed in parentheses. In the following SERIES formula, the values range consists of B2:B3 and B5:B7:

=SERIES(,,(Sheet1!$B$2:$B$3,Sheet1!$B$5:$B$7),1)

Although a SERIES formula can refer to data in other worksheets, all the data for a series must reside on a single sheet. The following SERIES formula, for example, is not valid because the data series references two different worksheets:

=SERIES(,,(Sheet1!$B$2,Sheet2!$B$2),1)

Using Names in a SERIES Formula

You can substitute range names for the range references in a SERIES formula. When you do so, Excel changes the reference in the SERIES formula to include the workbook name. For example, the SERIES formula shown here uses a range named MyData (located in a workbook named budget.xlsx). Excel added the workbook name and exclamation point.

=SERIES(Sheet1!$B$1,,budget.xlsx!MyData,1)

Chart-Making Tips

Here I present a number of chart-making tips that you might find helpful:

Using names in a series formula provides a significant advantage: If you change the range reference for the name, the chart automatically displays the new data. In the preceding SERIES formula, for example, assume the range named MyData refers to A1:A20. The chart displays the 20 values in that range. You can then use the Name Manger to redefine MyData as a different range-say, A1:A30. The chart then displays the 30 data points defined by MyData. (No chart editing is necessary.)

As I noted previously, a SERIES formula cannot use worksheet functions. You can, however, create named formulas (which use functions) and use these named formulas in your SERIES formula. As you see later in this chapter, this technique enables you to perform some useful charting tricks.

Unlinking a Chart Series from Its Data Range

Normally, an Excel chart uses data stored in a range. If you change the data in the range, the chart updates automatically. In some cases, you may want to "unlink" the chart from its data ranges and produce a static chart-a chart that never changes. For example, if you plot data generated by various what-if scenarios, you may want to save a chart that represents some baseline so you can compare it with other scenarios. There are two ways to create such a chart:

Категории