Figure 2-6. Tweaking the regional settings on your computer gives you complete control over how Excel recognizes dates. Use the pull-down menus to specify the date separator, order of month, day, and year components in a date, and how Excel should interpret two-digit years. You can mix and match these settings freely, although you could wind up with a computer that’s completely counter intuitive to other people.
Some worksheets require that you type in the same information row after row. For example, if you’re creating a table to track the value of all your Sesame Street collectibles, you can type in Kermit only so many times before you start turning green. Excel tries to help you out with its AutoComplete feature, which examines what you type, compares it against previous entries in the same column, and, if it recognizes the beginning of an existing word, fills it in.
For instance, in your Sesame Street worksheet, if you already have Kermit in the Characters column, when you start typing a new entry in that column beginning with the letter K, Excel automatically fills in the whole word Kermit. Excel then selects the letters that it’s added (in this case, ermit). You now have two options:
If you want to accept the AutoComplete text, move to another cell. For example, when you hit the right arrow key or press Enter to move down, Excel leaves the word Kermit behind.
If you want to blow off Excel’s suggestion, just keep typing. Because Excel automatically selects the AutoComplete portion of the word (ermit), your next keystrokes overtype that text. Or, if you find the AutoComplete text is distracting, press Delete to remove it right away.
If your cell meets any of the following criteria, Excel automatically treats the content as ordinary text:
It contains any punctuation that Excel can’t interpret numerically. Punctuation allowed in numbers and dates includes the comma (,), the decimal point (.), and the forward slash (/) or dash (-) for dates. When you type in any other punctuation, Excel treats the cell as text. Thus, 14! is text, not a number.
Occasionally, Excel reads your data the wrong way. For example, you may have a value like a social security number or a credit card number that’s made up entirely of numeric characters but that you want to treat like text because you don’t ever want to perform calculations with it. But Excel doesn’t know what you’re up to, and so it automatically treats the value as a number. You can also run into problems when you precede text with the equal sign (which tells Excel that you have a formula in progress), or when you use a series of numbers and dashes that you don’t intend to be part of a date (for example, you want to enter 1-2-3 but you don’t want Excel to read it as January 2, 2007which is what it wants to do).
In all these cases, the solution’s simple. Before you type the cell value, start by typing an apostrophe (’). The apostrophe tells Excel to treat the cell content as text. Figure 2-3 shows you how it works.

Figure 2-3. To have Excel treat any number, date, or time as text, just precede the value with an apostrophe (you can see the apostrophe in the formula bar, but not in the cell). This worksheet shows the result of typing 1-2-3, both with and without the initial apostrophe. When you store 1-2-3 as text, Excel left-aligns it, as if it were an all-text cell (and puts a tiny green triangle in the corner of the cell to let you know you may have made a mistake). The date, on the other hand, is right-aligned.
When you precede a numeric value with an apostrophe, Excel checks out the cell to see what’s going on. When Excel determines that it can represent the content as a number, it places a green triangle in the top left corner of the cell and gives you a few options for dealing with the cell, as shown in Figure 2-4.

Figure 2-4. In this worksheet, the number 42 is stored as text, thanks to the apostrophe that precedes it. Excel notices the apostrophe, wonders if it’s an unintentional error, and flags the cell by putting a tiny green triangle in the top-left corner. If you move to the cell, an exclamation mark icon appears, and, if you click that, a menu appears, letting you choose to convert the number or ignore the issue for this cell. Excel provides a similar menu if you enter a text date that has a two-digit year, as in ‘1-1-07. In this case, the menu allows you to convert the two-digit date to a four-digit date that has a year starting with 19 or 20.
One of Excel’s most important features is its ability to distinguish between different types of information. A typical worksheet contains both text and numbers. There isn’t a lot you can do in Excel with ordinary text (other than alphabetize a list, perform a simple spell check, and apply some basic formatting). On the other hand, Excel gives you a wide range of options for numeric data. For example, you can string your numbers together into complex calculations and formulas, or you can graph them on a chart. Programs that don’t try to separate text and numbers like Microsoft Word, for example can’t provide these features.
Most of the time, when you enter information in Excel, you don’t explicitly indicate the type of data. Instead, Excel examines the information you’ve typed in, and, based on your formatting and other clues, classifies it automatically. Excel distinguishes between four core data types:
Ordinary text. This data type includes column headings, descriptions, and any content that Excel can’t identify as one of the other data types.
Numbers. This data type includes prices, integers, fractions, percentages, and every other type of numeric data. Numbers are the basic ingredient of most Excel worksheets.
Dates and times. This data type includes dates (like Oct 3, 2007), times (like 4:30 p.m.), and combined date and time information (like Oct 3, 2007, 4:30 p.m.). You can enter date and time information in a variety of formats.
True or false values. This data type (known in geekdom as a Boolean value) can contain one of two things: TRUE or FALSE (displayed in all capitals). You don’t need Boolean data types in most worksheets, but they’re useful in worksheets that include Visual Basic macro code or that use complex formulas that evaluate conditions.
One useful way to tell how Excel is interpreting your data is to look at cell alignment, as explained in Figure 2-1.

Figure 2-1. Unless you explicitly change the alignment, Excel always left-aligns text (that is, it lines it up against the left edge of a cell), as in column A. On the other hand, it always right-aligns numbers and dates, as in columns B and C. And it centers Boolean values, as in column D.
As Figure 2-1 shows, Excel can display numbers and dates in several different ways. For example, some of the numbers include decimal places, one uses a comma, and one has a currency symbol. Similarly, one of the time values uses the 12-hour clock while another uses the 24-hour clock. Other entries include only date information or both date and time information. You assume that when you type in a number, it will appear in the cell exactly the way you typed it. For example, when you type 3-comma-0-0-0 you expect to see 3,000. However, that doesn’t always happen. To see the problem in action, try typing 3,000 in a cell. It shows up exactly the way you entered it. Then, type over that value with 2000. The new number appears as 2,000. Excel remembers your first entry, and assumes that you want to use thousand separators in this cell all the time.
These differences may seem like a spreadsheet free-for-all, but don’t despairyou can easily set the formatting of numbers and dates. At this point, all you need to know is that the values Excel stores in each cell don’t need to match exactly the values that it displays in each cell. For example, the number 4300 could be formatted as plain old 4300 or as the dollar amount $4,300. Excel lets you format your numbers so you have exactly the representation you want. At the same time, Excel treats all numbers equivalently, no matter how they’re formatted, which lets you combine them together in calculations. Figure 2-2 shows you how to find the underlying stored value of a cell.

Figure 2-2. You can see the underlying value that Excel is storing for a cell by selecting the cell and then glancing at the formula bar. In this sheet, you can see that the value $299.99 is actually stored without the dollar currency symbol, which Excel applied only as part of the display format. Similarly, Excel stores the number 2,000 without the comma; it stores the date 1-Jun-07 as 6/1/2007; the time 12:30 p.m. as 12:30:00 PM, and the time 14:00:00 as 2:00:00 PM.
Technorati Tags: add different data type
]]>
In these complex and uncertain times, forecasting business performance is increasingly important. Today, more than ever, managers at all levels need to make intelligent predicÂtions of future sales and profit trends as part of their overall business strategy. By forecastÂing sales six months, a year, or even three years down the road, managers can anticipate related needs such as employee acquisitions, warehouse space, and raw material requireÂments. Similarly, a profit forecast enables the planning of the future expansion of a comÂpany.
Business forecasting has been around for many years, and various methods have been developed-some more successful than others. The most common forecasting method is the qualitative “seat-of-the-pants” approach, in which a manager (or a group of managers) estimates future trends based on experience and knowledge of the market. This method, however, suffers from an inherent subjectivity and a short-term focus because many manÂagers tend to extrapolate from recent experience and ignore the long-term trend. Other methods (such as averaging past results) are more objective but generally useful for foreÂcasting only a few months in advance.
In business, it’s becoming increasingly popular to use a statistical tool called regression analyÂsis to determine the relationship between one phenomenon that depends on another. For example, car sales might be dependent on interest rates, and units sold might be dependent on the amount spent on advertising. The dependent phenomenon is called the dependent variable or the y-value, and the phenomenon upon which it’s dependent is called the indeÂpendent variable or the x-value. (Think of a chart or graph on which the independent variÂable is plotted along the horizontal [x] axis and the dependent variable is plotted along the vertical [y] axis.)
Given these variables, you can do two things with regression analysis:
With linear data, the dependent variable is related to the independent variable by some constant factor. For example, you might find that car sales (the dependent variable) increase by one million units whenever interest rates (the independent variable) decrease by 1 perÂcent. Similarly, you might find that division revenue (the dependent variable) increases by $100,000 for every $10,000 you spend on advertising (the independent variable).
You make these sorts of determinations by examining the trend underlying the current data you have for the dependent variable. In linear regression, you analyze the current trend by calculating the line of best-fit, or the trendline. This is a line through the data points for which the differences between the points above and below the line cancel each other out (more or less).
The easiest way to see the best-fit line is to use a chart. Note, however, that this works only if your data is plotted using an XY (scatter) chart. For example, Figure 1 shows a workÂsheet with quarterly sales figures plotted on an XY chart. Here, the quarterly sales are the dependent variable, and the period is the independent variable. (In this example, the indeÂpendent variable is just time, represented, in this case, by fiscal quarters.)
The following steps show you how to add a trendline to a chart:
Figure 2 shows the best-fit trendline added to the chart.
CAUTION
It’s important not to view the trendline values as somehow trying to predict or estimate the actual y-values (sales).The trendline simply gives you an overall picture of how the y-values change when the x-values change.

Figure 1 To see a trendline through your data, first make sure the data is plotted using an XY chart.

Figure 2 The quarterly sales chart with a best-fit trendline added.
Technorati Tags: plotting best fit, best fit trendline
]]>
Earlier in this chapter, you learned how to create a chart that expands automatically as you add new data points (see “Automatically Expanding a Chart to Include New Data”). It’s a useful trick that I use all the time, but it does lead to one problem: You can end up with a lot of data points in the chart, and after awhile you have to resize the chart horizontally to maintain the visual integrity of the plot. Of course, that leads to an entirely different probÂlem: Eventually your chart becomes wider than the Excel window, so you need to use the horizontal scroll bar to see different parts of the chart.
A better solution is to keep your chart the same size but add a scrolling element to it that enables you to move back and forth through the data. You set this up by adding a scroll bar to the worksheet and using the values generated by the scroll bar to create dynamically named ranges that change as the scroll bar value changes. Then, as you saw earlier in this chapter (see “Charting a Dynamic Range”), you configure your chart to use these dynamiÂcally named ranges. The result is that as you scroll forward and backward in the scroll bar, the data plotted on the charts moves forward and backward by the same amount.
You begin by converting your worksheet data to a table. Figure 1 shows the example data that I use in this section. It’s a table (named Table2) of monthly sales that runs from January, 1998 to December, 2007. I plot the Month and Actual columns in the chart.

Figure 1 As an example in this section, I create a scrolling chart for 10Âyear’s worth of monthly sales data.
Next, you add the scroll bar. First, insert two values in the worksheet:
You are now ready to add the scroll bar to the worksheet. Here are the steps to follow:
NOTE
If you don’t see the Developer tab, choose Office, Excel Options to open the Excel Options dialog box. In the Popular tab, click to activate the Show Developer tab in the Ribbon check box and then click OK.
TIP
If you want to resize the scroll bar or make other changes to it, you first need to select it.To do this, hold down Ctrl and then click the scroll bar.
Figure 2 shows the Monthly Sales worksheet with the scroll bar added and its filled in Format Control dialog box. For future reference, note that I have applied the named Months_to_Display to cell G2 and the name Starting_Month to cell G3.
Next, you need to define your dynamically named ranges. As before, you need to use the OFFSET() function, which you should set up as follows:

Figure 2 A scroll bar added to the worksheet and configÂured for the monthly sales data.
In the monthly sales example, I created the name Monthly_Sales_Categories and assigned it the following formula:
=OFFSET(Table2[[#Headers],[Month]],Starting_Month, 0, Months_to_Display, 1)
I also created the name Monthly_Sales_Values and assigned it the following formula:
=OFFSET(Table2[[#Headers],[Actual]],Starting_Month, 0, Months_to_Display, 1)
Finally, create a chart and set up the type and formatting you want to use. It’s important, however, to not plot the entire table. Instead, just plot the same number of points that you want to display in the chart. In the monthly sales example, I want to display 12 months at a time, so I plotted only the first 12 months of data in the table. When that’s done, modify the references to the category labels and series values, as described in this chapter’s “Charting a Dynamic Range” section.
Figure 3 shows the scrolling chart for the monthly sales data. Notice that the current scroll bar value is 13 (see cell G3) and that the chart plot begins with January, 1999, which is the 13th value in the table.

Figure 3 The scrolling chart for the monthly sales table.
Technorati Tags: scrolling chart, excel 2007
]]>
In earlier Figure, I exploded one of the pie chart slices and then added a shape with some explanatory data about the composition of the Others slice. In most pie charts, you use an “Others” slice because the components data that makes up this item are too small to show properly on the pie chart. That is, the slices would be so thin that they’d be hard to pick out from the surrounding slices.
If you want others to see the data represented by an “Others” slice, Excel offers another pie chart type that’s ideal: The Bar of Pie type. With this chart type, the smallest data items are gathered into a single slice, as before, but then the separate items that comprise that slice are displayed in a separated stacked bar marker.
To create a Bar of Pie chart, select your data, choose Insert, Pie, Bar of Pie. Figure 1 shows an example.

Figure 1 A Bar of Pie chart shows the data series’ small valÂues in a separate stacked bar marker.
Technorati Tags: chart small values, bar pie chart, excel 2007
]]>
A pie chart shows the proportion of the whole that is contributed by each value in a single data series. The whole is represented as a circle (the “pie”), and each value is displayed as a proportional “slice” of the circle. You can use pie charts to represent sales figures proporÂtionally by region or by product, or to show population data such as age ranges or voting patterns.
To create a pie chart, select your data, choose Insert, Pie, and click the pie chart type you want. In the pie chart gallery, notice that Excel includes an Exploded Pie type. In pie chart lingo, exploding a slice means separating that slice by some amount so that it appears on its own. This is a useful way to highlight a special slice. However, the Exploded Pie type explodes every slice, which isn’t that useful. If you want to explode just a single slice, you need insert a regular pie chart and then follow these steps:
NOTE
An explosion value of 100% means that the tip of the slice lies on the circumference of the pie. A value greater than 100% means the slice will be displayed completely outside of the pie.
Figure 1 shows a pie chart that plots the proportions of Earth’s elements, with the Others slice exploded so that a shape can point out extra information about the slice’s value.

Figure 1 A pie chart showing the proportions of terrestrial elements, with the Others slice exploded.
Technorati Tags: explode slice, pie chart
]]>
If you plot two different series on the same chart, the result won’t look good if the two series use wildly different data ranges. A good example is a stock chart that includes one series for closing prices and another series for volume. The prices might be measured in tens of dollars, whereas the volumes might be measured in tens of thousands of units. How can you combine these two disparate data sources so that you can see both series properly?
The trick here is to add another vertical axis-called the secondary axis-and tell Excel to plot one of the series using that axis. Here are the steps to follow:
Figure 1 shows an example chart with two vertical axes-the primary axis (on the left) plots the Close series, and the secondary axis (on the right) plots the Volume series.

Figure 1 If you have series with wildly different data valÂues, plot one of them on the secondary axis.
Technorati Tags: dispaly second vertical axis
]]>
Most charts use static data as their data source. However, it’s not uncommon for a chart to use a data source that constantly expands. On a stock price worksheet, for example, you might enter daily prices for a given month. Rather than wait until the end of the month to create the chart, it is useful to chart the existing data and update the chart as you add new prices each day.
The hard way to accomplish this is to edit the range references for the category axis labels and data series values each time you add new data. Fortunately, Excel 2007 gives you a much easier method. As with the dynamic ranges you learned about in the previous section, the trick is to convert your data to a table. When the category axis label range and data series range are part of a table, Excel automatically expands the chart to include any new data that you add to the table. Note that you get this advantage without any other fuss and bother. As soon as you convert the data range to a table, your chart becomes dynamic based on the table data. You don’t need to edit the SERIES() function or perform any other arcane tasks.
NOTE
Another advantage you get with this trick is that it doesn’t matter when you convert the data to a table.You can perform the conversion either before or after you’ve created your chart; Excel will still expand the chart automatically to accommodate new table data.
Technorati Tags: expanding chart automatically, new data excel
]]>
Most chart data consists of an entire range of cells, but it’s sometimes necessary to chart only a portion of a range. If you have stock data, for example, you may want to visualize only a particular 7-, 14-, or 30-day portion of the data. If the chart doesn’t exist yet, just select the portion of the range you want to work with and then insert the chart. If the chart already exists, there are two methods you can use to adjust the data series:
Here’s the syntax for the SERIES() function:
SERIES([name,][ category_labels,] values, order)
|
For example, here’s the SERIES() function for the line chart that displayed earlier:
=SERIES(‘Worksheet Text’!$B$2,’Worksheet Text’!$A$3:$A$24,
➥’Worksheet Text’!$B$3:$B$24,1)
However, what do you do if the sub-range you want to plot changes over time? For examÂple, in a stock price worksheet where you enter prices daily, it is useful to use chart that always shows, say, the most recent 7 days of price data. Is it possible to set this up without having to redefine the series ranges by hand? Absolutely! Using a couple of tricks, you can create a chart that automatically plots a dynamic range.
As an example, I show you how to set up a chart that automatically plots the most recent 7 days of stock data. This task is made easier by Excel 2007’s new structured table references. I won’t go into this in detail except to say that when you convert a range to a table, Excel 2007 defines a name for that table. Most importantly for our purposes, as you add data to or remove data from the table, Excel 2007 dynamically adjusts the references associated with the table name.
NOTE
For a more detailed look at Excel 2007’s structured table referencing, see my book Formulas and Functions with Microsoft Excel 2007 (Que 2007; ISBN 0-7897-3668-3).
Therefore, the first thing you need to do is convert your worksheet data to a table. Select your data (including any column headers) and choose Insert, Table to display the Create Table dialog box. Make sure the range is correct, activate the My Table Has Headers check box, and then click OK. Make a note of the table name (select the table data-don’t include the headers-and see the name that displays in Excel’s Name box). The default name is Tablen, where n means this is the nth table you’ve added to the current workbook.
The next stage is to create two dynamic range names-one for the category axis labels and one for the data series values. A dynamic range name is one that automatically adjusts based on the results of the function or functions used to define the name. In this case, you want to create names that dynamically adjust to always return the last seven items in the table you just created.
To make the range name formulas easier to understand, add the range length you want (7, in this case) to a cell and then name that cell Length.
TIP
The easiest way to apply a range name to a cell is to click the cell, type the name in the Name box (the text box that displays to the left of the formula bar), and then press Enter.
There are several methods you can use to create a dynamic range name. I like to use the OFFSET() function, which returns a range offset from some original range by a specified number of rows and columns:
OFFSET(reference, rows, cols[, height][, width])
|
Our goal is to create an OFFSET() formula that returns the last length number of items in the table, where length is the value you stored in the cell named Length, earlier. You do this by offsetting to the length-last item in the table and then setting the height argument equal to length.
For the category (X) axis labels, assuming the category labels start at cell A3 in the table, then the following OFFSET() formula does the job:
=OFFSET($A$3, ROWS(Table1) – Length, 0, Length, 1)
To use this formula as the basis of a dynamic range name, follow these steps:
For the data series values, assuming the series values start at cell B3 in the table, the followÂing OFFSET() formula does the job:
=OFFSET($B$3, ROWS(Table1) – Length, 0, Length, 1)
To use this formula as the basis of a dynamic range name, follow the same steps that I outÂlined previously (entering a different range name, such as Values).
Now, all that remains is to adjust the chart references to point at these two new dynamic range names. Use the techniques I mentioned earlier in this section (using the Select Data Source dialog box or editing the SERIES() function directly). For best results, include the workbook name in the references, as shown here:
=SERIES($B$2,Chapter08.xlsm!Categories,Chapter08.xlsm!Values,1)
Figure 1 shows a chart based on these dynamic named ranges.

Figure 1 A chart based on dynamically named ranges.
Technorati Tags: dynamic range charting, excel 2007
]]>