Excel User Tips - Formatting
Excel User Tips - Formatting
To change the default formatting of your cell comments (so you don't have to repeat
that process each time), you need to go outside Excel and use the Windows Display
Settings dialog box. Excel uses the formatting specified for Windows' ToolTips (the text
that appear when your pointer hovers near toolbar buttons).
You can access the Display Settings dialog box from the Control Panel. Or, you can
right-click the desktop and choose Properties. Access the Appearance tab of the Display
Properties dialog box, and select the ToolTip item. You can then modify the font, the
font size, the background color, the foreground color, and the Bold and Italic attributes.
NOTE:
If you're using Windows XP, you need to click the Advanced button in the Appearance
tab of the Display Properties dialog box. This brings up the Advanced Appearance dialog
box, where you can make the change.
Be aware that this will affect all comments that have not been formatting. If you've
already applied formatting to a comment (for example, changed the background color),
that comment will not be affected by this change.
When entering text into the cell, press Alt-Enter to insert a line break.
When you do so, Excel will automatically apply text wrapping to the cell. To reformat
existing cells so they sport wrapped text, select the cells and then choose Format, Cells.
On the Alignment tab, select "Wrap text," and click OK.
Somehow Excel's fixed-decimal mode was turned on. To return to normal, select Tools,
Options to display the Options dialog box. Then click the Edit tab and remove the
checkmark from the "Fixed decimal" option.
Of course, this feature can be useful when entering some types of data, but most of the
time, you'll want to keep the fixed-decimal mode turned off.
The worksheet below shows student grades on two tests. Conditional formatting
highlights students who scored higher on the second test. This formatting is dynamic; if
you change the test scores, the formatting adjusts automatically.
To apply conditional formatting, select range A2:C15 and choose Format, Conditional
Formatting. The Conditional Formatting dialog box will appear with two input boxes. In
the first box, choose Formula Is, press Tab, and enter the following formula:
=$C2>$B2
The conditional formatting formula is evaluated for each cell in the range. The trick here
is to use mixed cell references (the column references are absolute, but the row
references are relative). To see how this works, activate any cell within the range and
choose Format, Conditional Formatting so you can examine the conditional formatting
formula for that cell. You'll find that cell A7, for example, uses this formula:
=$C7>$B7.
When you enter a fractional value, Excel automatically applies a fraction number format
that reduces it to the smallest possible denominator. For example, if you enter 16 2/8,
Excel displays the number as 16 1/4. In some cases, however, you'll want the fractions
to use a common denominator. For example, you might want the value 16 2/8 to be
shown as 16 4/16. To obtain this result, select your cells and choose Format, Cells.
Then select the Number tab and choose Fraction from the Category list. Finally, select
the desired number format from the Type list.
The worksheet below shows some examples of numbers expressed as fractions. Column
B shows the numbers produced using Excel's default formatting. Column C has the
same values formatted as 16ths.
You can also express fractional data using a decimal point. For instance, the number 9
4/16 could appear as 9.04. Here, the digits to the right of the decimal represent 16ths.
To display values in this format, use Excel's DOLLARFR() function. It's available only
when the Analysis ToolPak is installed (select Tools, Add-ins to install it). The
DOLLARFR() function takes two arguments: the number and an integer for the
denominator. The formula =DOLLARFR(9.25,16), for example, returns 9.04.
The DOLLARFR() function is for display only. You can't use the value it returns in other
calculations or in charts. To perform calculations on such values, reconvert them into
decimal values by using the DOLLARDE() function (also part of the Analysis ToolPak).
For example, the formula below displays a blank if the division results in an error.
=IF(ISERROR(A1/B1),"",A1/B1)
You can adapt this technique to any operation. The original formula serves as the
argument for the ISERROR() function, and it repeats as the last argument of the IF()
function. Like this:
=IF(ISERROR(OriginalFormula),"",OriginalFormula)
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.
You may want to make the subtotal rows stand out by applying special formatting.
However, this can't be done by any of Excel's autoformats. Use the outline controls on
the left side of the workbook to collapse the outline so only the subtotal rows are
visible. Press F5, select Visible Cells Only, and click OK. Then apply formatting to the
selected cells.
When you expand the outline, only the subtotal rows will have the formatting you
applied.
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.
To make an AutoShape even snazzier, double-click the graphic to access the Format
AutoShape dialog box. From there, you can apply formatting changes -- for instance,
adjusting the vertical or horizontal positioning, changing the font, adding color, or
making the text bold.
If you use Excel 2000, you're out of luck. There is no way to turn this potentially
annoying feature off. But you can, however, override it. If Excel creates a hyperlink
from your cell entry, click the Undo button (or press Ctrl-Z) to restore the cell's contents
to normal text. Or, you can precede the cell entry with an apostrophe.
Note: If you're using Excel 2002, you can turn automatic hyperlinks on or off in the
AutoCorrect dialog box
To create the macro, press Alt-F11 to activate the Visual Basic Editor, select Insert,
Module to insert a new VBA module into your project, and then enter the following
code:
Sub ZapHyperlinks()
Cells.Hyperlinks.Delete
Column A consists of formulas that refer to column B. The formula in cell A1 is:
=IF(B1<>"",COUNTA($B$1:B1)&".","")
This formula, which is copied down to the other cells in column A, displays the next
consecutive item number if the corresponding cell in column B is not empty. If the cell
in column B is empty, the formula displays nothing.
As items are added or deleted from column B, the numbering updates automatically.
For example, assume cell A12 contains the value 1435. Enter the following formula into
another cell:
="Total: "&A12
The formula cell will display: "Total: 1435."
The ampersand is a concatenation operator that joins the text with the contents of cell
A12.
Applying a number format to the cell containing the formula has no effect, because the
cell contains text, not a value. As a work-around, modify the formula to use the TEXT
function (the second argument for the TEXT function consists of a standard Excel
number-format string).
="Total: "&TEXT(A12,"$#,##0.00")
Here's another example formula that uses the NOW function to display some text along
with the current date and time:
="Report printed on "&TEXT(NOW(),"mmmm d, yyyy at h:mm AM/PM")
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.
3. In the Conditional Formatting dialog box, select Formula Is from the drop-down
list, and enter this formula:
=MOD(ROW(),2)=0.
The best part is that the row shading is dynamic. You'll find that the row shading
persists even if you insert or delete rows within the original range.
This clever technique was submitted by David Hager. It uses Conditional Formatting
(available in Excel 97 or later) to apply special formatting to cells that contain formulas-
-something that's not normally possible. With this technique you can set up your
worksheet so that all formula cells get a yellow background, for example, or so that
negative values are in boldface.
CellHasFormula
3. Then enter the following formula in the "Refers to" box
=GET.CELL(48,INDIRECT("rc",FALSE))
4. Click Add, and then OK.
5. Select all the cells to which you want to apply the conditional formatting.
6. Select Format, Conditional Formatting
7. In the Conditional Formatting dialog box, select Formula Is from the drop-down
list, and then enter this formula in the adjacent box (see the figure below):
=CellHasFormula
8. Click the Format button and select the type of formatting you want for the cells
that contain a formula.
9. Click OK.
After you've completed these steps, every cell that contains a formula and is within the
range you selected in Step 4 will display the formatting of your choice.
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
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.