Excel User Tips - Chart - and - Graphic
Excel User Tips - Chart - and - Graphic
Prior to Excel 2002, a common question was: "How can I insert my company's logo
into the page header?" The simple answer: You can't. But there are a few ways to
fake it.
Perhaps the simplest solution is to print your reports on company letterhead -- paper
that's preprinted with your logo. Another option is to use a custom font with a
character that displays your logo. You can create this custom font using shareware or
commercial font creation programs, or hire a professional to do the job. But even
professionals will be limited to the use of simple line graphics.
Another way to display a graphic within a page header involves a bit of trickery. Excel
lets you specify that one or more rows print at the top of every page (these are
known as print titles). You can take advantage of this option and use a print title row
to store your logo.
The figure below shows a graphic that will print at the top of each page. Note that the
row height is adjusted to fit the image.
First, specify the rows for the print titles. Choose File, Page Setup and click on the
Sheet tab in the Page Setup dialog box. This example uses the first two rows as the
print titles, so that both the graphic (row 1) and the column headers (row 2) will
appear at the top of every printed sheet.
You can also combine standard header options (found in the Header/Footer tab of the
Page Setup dialog) with this title rows trick -- but make sure the graphic doesn't
obscure the text. For example, if the graphic sits on the left side of the page (as in the
example), you'll need to put the page numbers in the right or center sections of the
sheet's header.
Now here's where it gets tricky. Click the Print Preview button to preview your
worksheet. In the preview window, click the Margins button to display the margin
handles, which let you adjust the margins and column widths. Specifically, you'll need
to adjust the top margin and the header margin, represented by horizontal lines in the
preview window. Normally, the upper horizontal line represents the header margin,
and the second horizontal line the top margin. Drag these lines up or down until the
page header looks correct. In the figure linked to above, the header margin has been
moved above the page margin, so the page margin overlaps with the header margin.
The result is that the graphic will align vertically with the normal header text (in the
example shown, the page number).
3. Hold down the Shift key, and then choose Edit, Paste Picture Link.
The result is an image of the selected range that will reflect any subsequent changes
to the source.
This technique is great for printing noncontiguous ranges on a single page. After
creating a series of linked pictures of ranges, set them to print on one page.
Note: The Paste Picture Link command is a hidden command, and it appears on the
Edit menu only if you press the Shift key.
The figure below shows an example of what you can produce with his technique.
To re-create this chart in Excel, enter the data shown in columns A through D, and
then enter the following formulas:
E2: =IF(D2<0,REPT("n",-ROUND(D2*100,0)),"")
F2: =A2
G2: =IF(D2>0,REPT("n",-ROUND(D2*-100,0)),"")
Depending on the numerical range of your data, you may need to change the scaling.
Experiment by replacing the '100' value in the formulas. You can, of course, substitute
any character you like for the "n" in the formulas to produce a different character in
the chart.
The example below tracks daily progress toward a goal: 1000 new customers in a 15-
day period.
Cell B18 contains the goal value. Cell B19 contains a simple sum formula:
=SUM(B2:B16)
Cell B21 contains the following formula, which calculates the percentage of the goal
attained
=B19/B18
As new data is entered in column B, the formulas display the current results.
1. Enter the formulas listed above, along with the worksheet's sample data.
3. In step 1 of the Chart Wizard dialog, specify a Column chart and a Clustered
Column subtype (the first choice).
4. Click Next twice, and then in step 2 make additional adjustments: Add a Chart
Title (Title tab), dump the Category (x) axis (Axes tab), delete the legend
(Legend tab), and specify Show value (Data Labels tab). Click Finish to view
the chart.
5. Double-click the column to display the Format Data Series dialog box.
6. Click the Options tab, and set the Gap width to 0 (this setting instructs the
column to occupy the entire width of the plot area).
7. To change the pattern used in the column, click the Patterns tab and make
your selection. The example shown here uses a gradient fill effect.
8. Double-click the vertical axis to bring up the Format Axis dialog. In the Scale
tab of the Format Axis dialog, set Minimum to 0 and Maximum to 1.
This tip describes how to make a bar or column series transparent by pasting a
picture. The figure below shows a chart after the column series has been made
transparent. Notice that the gridlines show through the columns.
In the example below, the transparent AutoShape was formatted with a rainbow
gradient.
• Column - Area
• Line - Column
Many users think that these are the only two combination charts that are possible. In
fact, you have a great deal of flexibility in creating combination charts. They key is
understanding how the Chart - Chart Type command works. When you select this
command, it works in either of two ways:
Or...
For example, assume you want to create a combination chart that displays a column,
a line, and an area.
Create charts as usual, placing them in a worksheet. Select any blank cell in the
worksheet and press F11; this creates an empty Chart sheet to hold the embedded
charts. Reactivate your worksheet, click an embedded chart, and select Chart,
Location to display the Chart Location dialog box. Choose "As object in" and specify
the empty Chart sheet. Excel will transfer the embedded chart to your Chart sheet.
Select your remaining charts, and use Chart, Location to move them to the Chart
sheet. Now you can arrange and size the charts any way you like. Putting multiple
charts on a single Chart sheet lets you use the View, Sized with Window command
(available when the Chart sheet is active) to scale the charts to the window size and
dimensions.
Following is an example of a Chart sheet that contains three charts. When the window
is resized, the charts adjust to fill the window automatically.
First, click the AutoShapes button on the Drawing toolbar, select the shape you want
to use by clicking it, and click in the formula bar. Then enter a cell reference such as
the following:
=$B$14
Press Enter. In the example below, the contents of cell B14 will then be displayed
inside the AutoShape. If the content of the referenced cell changes, the graphic will
reflect the change. The advantage is that AutoShapes offer formatting options that
are not available within the standard Format menus.
First, select the cells to be formatted, then choose Format, Cells. Click the Number
tab. Select Custom from the Category list, and in the Type box enter 0, (that's a zero
followed by a comma).
When this number format is applied, the cells will retain the correct numerical values,
but they will be displayed without the last three digits.
To display values in millions, insert an additional comma at the end of the format
string (0,,).
You can also use these number formats in charts. To do so, double-click the chart axis
to display the Format Axis dialog box. Then click the Number tab and specify the
desired format. In Excel 2000 and later, the Scale tab of the Format Axis dialog box
lets you specify the unit scaling directly. Just choose Millions from the "Display units"
drop-down box.
• Interpolate the data by connecting the line between the nonmissing data
points.
The figure below shows both options. In this example, interpolating the missing data
seems the better choice in view of the data's time-based nature.
You can also represent data with the formula =NA() instead of leaving a cell blank.
The chart will use interpolation for data cells that contain this formula, regardless of
the setting in the Options dialog box.
In Step 2 of Excel's Chart Wizard dialog box, you can specify how the data will be
plotted. Choose either Rows or Columns for the "Series in" option (you'll be able to
preview your choice). To change the way the data in an existing chart is plotted,
select the chart by clicking it, then choose Chart, Source Data. In the Source Data
dialog box, click the Data Range tab and then make your selection
The only potential problem with this technique is that you can no longer edit the text
or modify the formatting of the graphic.
Method 2
Another option is to delete the text from your AutoShape, and use WordArt for the
text. Then you can group these two objects (the WordArt and the AutoShape). After
doing so, both objects will rotated together.
You can save your worksheet as an HTML file, and Excel will automatically convert any
charts to GIF files. If that seems like overkill, you can write a simple macro that will
do the job.
Press Alt-F11 to activate the Visual Basic editor. Select your workbook in the Projects
window, and choose Insert, Module to insert a new VBA module. Then type the
following four-line procedure into the module:
Sub SaveChartAsGIF ()
Fname = ThisWorkbook.Path & "\" & ActiveChart.Name & ".gif"
ActiveChart.Export FileName:=Fname, FilterName:="GIF"
End Sub
After the macro is entered, reactivate Excel and click the chart to be saved. Press Alt-
F8 to display the Macro dialog box. Select the SaveChartAsGIF macro and click Run.
The procedure uses the chart's name as the GIF file name, and the file is stored in the
same directory as the workbook. This simple macro does no error checking, so it will
generate an error if a chart is not selected or if the workbook has not been saved.
One way to create a static chart is to copy and paste it as a picture. Activate your
chart, hold down the Shift key, and choose Edit, Copy Picture (this option is available
only when you hold down Shift as you select Edit). The Copy Picture dialog box will
appear. Click OK to accept the defaults. Then click anywhere in your worksheet and
choose Edit, Paste.
Another way to create a static chart is to convert the range references into arrays.
Select a chart series and then click the formula bar to activate the SERIES() formula.
Press F9 to convert the range references into arrays. Repeat this for each series in the
chart. Now the chart cans till be formatted (it doesn't become a picture). The formula
bar in the figure below shows the SERIES() formula after converting the range
references to arrays.
When you select a chart series in Excel 97 or later, the ranges used by the series are
outlined on the worksheet. You could simply drag a corner of the outline to extend the
range.
This document describes another approach that uses formulas to define the ranges
used in a chart. The steps listed below describe how to create dynamic ranges for the
chart shown in figure below.
2. Select Insert, Name, Define to bring up the Define Name dialog box.
3. In the 'Names in workbook' field, enter Date. In the 'Refers to' field, enter this
formula:
=OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet1! $A:$A)-1)
4. Click Add to create the name. Notice that the OFFSET function refers to the
first data point (cell A2) and uses the COUNTA function to get the number of
data points in the column. Because column A has a heading in row 1, the
formula subtracts 1 from the number.
5. Now type Sales in 'Names in workbook', and in 'Refers to' enter this formula:
=OFFSET(Sheet1!$B$2,0,0,COUNTA(Sheet1!$B:$B)-1)
7. Activate the chart and select the data series. In this example, the
(unmodified) formula in the formula bar will read:
=SERIES(Sheet1!$B$1,Sheet1!$A$2:$A$10, Sheet1!$B$2:$B$10,1)
8. Replace the range references in the SERIES formula with the names you
defined in steps 4 and 5. The SERIES formula should read:
=SERIES(,Sheet1!Date,Sheet1!Sales,1)
After performing these steps, you'll find that the chart updates automatically when
you add new data to the worksheet. .
To use this technique for your own data, make sure that the first
argument for the OFFSET function refers to the first data point, and
that the argument for COUNTA refers to the entire column of data.