You are on page 1of 5

J-Walk & Associates, Inc.

Home Books Products Tips Dow nloads Resources Blog Support


Search

Delete All Input Cells, But Keep The Formulas


Excel Tips
Excel has a long history, and it continues C ategory: Formulas | [Item URL]
to evolve and change. C onsequently, the
tips provided here do not necessarily Your w orksheet may be set up w ith formulas that operate on a number of input cells. Here's an
apply to all versions of Excel. easy w ay to clear all input values w hile keeping the formulas intact.
In particular, the user interface for Excel
Press F5 to display the Go To dialog box, and click the Special button. In the Go To Special
2007 (and later), is vastly different from
its predecessors. Therefore, the menu dialog, choose the Constants button and select Numbers. W hen you click OK, the nonformula
commands listed in older tips, will not numeric cells w ill be selected. Press Delete to delete the values. The Go To Special dialog box
correspond to the Excel 2007 (and later) has many other options for selecting cells of a particular type.
user interface.

All Tips
List all tips, by category
Round Values To The Nearest Fraction
Browse all tips C ategory: Formulas | [Item URL]

Q. Is it possible to round a dollar amount to the nearest 25 cents? For example, if a


Browse Tips by Category
number appears as $1.65, I would like to convert it to $1.75. Excel's ROUND() function
General seems to work only with whole numbers.
Formatting
Formulas Yes, you can use Excel's ROUND() function to achieve the rounding you w ant. The follow ing
Charts & Graphics formula, w hich assumes that your value is in cell A1, w ill do the job for you.
Printing
General VBA
=ROUND(A1/.25,0)*.25
CommandBars & Menus The formula divides the original value by .25 and then multiplies the result by .25. You can, of
UserForms course, use a similar formula to round values to other fractions. For example, to round a dollar
VBA Functions amount to the nearest nickel, simply substitute .05 for each of the tw o occurrences of ".25" in
the preceding formula.
Search for Tips
Search: Avoid Error Displays In Formulas
Go
C ategory: Formulas | [Item URL]
Advanced Search
Sometimes a formula may return an error message. Usually, you'll w ant to know w hen a
formula error occurs. But now and then you may prefer to avoid the messages. You can do so
Tip Books by using an IF() function to check for an error.
Needs tips? Here are two books, with
nothing but tips:
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)

Change Cell Values Using Paste Special


C ontains more than 200 useful tips and
tricks for Excel 2007 | Other Excel 2007 C ategory: Formulas | [Item URL]
books | Amazon link: John
Walkenbach's Favorite Excel 2007 Q. I have a price list stored in a worksheet, and I need to increase all prices by 5 percent.
Tips & Tricks Can I do this without reentering all the prices?

Excel provides tw o w ays to accomplish this. The "traditional" technique goes something like
this:

1. Insert or find a blank column near the prices.


2. In that column's first cell, enter a formula to multiply the price in that row by 1.05.
3. Copy the formula dow n the column.
4. Select and copy the entire column of formulas
5. Select the original prices, and choose Edit, Paste Special.
C ontains more than 200 useful tips and
tricks for Excel | Other Excel 2003 6. In the Paste Special dialog box, select Values to overw rite the original prices w ith the
books | Amazon link: John formulas' results.
Walkenbach's Favorite Excel Tips & 7. And finally, delete the column of formulas.
Tricks
The other, more efficient approach also uses the Paste Special dialog box. To increase a range
of values (prices, in this example) by 5 percent:

1. Enter 1.05 into any blank cell.

converted by Web2PDFConvert.com
1. Enter 1.05 into any blank cell.
2. Select the cell and choose Edit, Copy.
3. Select the range of values and choose Edit, Paste Special.
4. Choose the Multiply option and click OK.
5. Delete the cell that contains the 1.05.

Hiding Your Formulas


C ategory: Formulas | [Item URL]

Q. I've created some clever formulas, and I don't want anyone else to see them. Is it
possible to hide the formulas but display the results?
Every cell has tw o key properties: locked and hidden. A locked cell can't be changed, and the
contents of a hidden cell don't appear in the formula bar w hen the cell is selected. By default,
every cell is locked and not hidden. But it's important to remember that these attributes have
no effect unless the w orksheet itself is protected.

First, to change the attributes, select the appropriate cell or range and then choose Format,
Cells. In the Format Cells dialog box, click the Protection tab and select Locked or Hidden (or
both). Unlock cells that accept user input, and lock formula and other cells that should stay
unchanged (such as titles). To prevent others from seeing your formulas, lock and hide the
formula cells: The results of the formulas w ill be visible, but the formulas w ill not.

Now , to protect the w orksheet, choose Tools, Protection, Protect Sheet to bring up the Protect
Sheet dialog box. Make sure the Contents box is checked. You can enter a passw ord to
prevent others from unprotecting the sheet. Locked cells in a protected sheet cannot be
edited, and other w orksheet changes are disabled. For example, no one can insert row s or
columns, change column w idth, or create embedded charts.

NOTE: Keep in mind that it is very easy to break the passw ord for a protected sheet. If you
are looking for real security, this is not the solution.

Counting Distinct Entries In A Range


C ategory: Formulas | [Item URL]

Q. Can I write a formula that returns the number of distinct entries in a range?
First, let's clarify the question. We're hunting for a formula that, given the range that contains
the values 100, 99, 98, 100, 98, 100, 98, w ould return 3. In other w ords, this range contains
three different values, some of them repeated.

This type of counting requires an array formula. The formula below , for example, counts the
number of distinct entries in the range A1:D100.

=SUM(1/COUNTIF(A1:D100, A1:D100))
W hen you enter this formula, you must press Ctrl-Shift-Enter. Pressing only Enter w ill give you
the w rong result. Excel w ill place brackets around the formula to remind you that you've
created an array formula.

The preceding formula w orks fine in many cases, but it w ill return an error if the range contains
any blank cells. The formula below (also an array formula, so input it w ith Ctrl-Shift-Enter) is
more complex, but it w ill handle a range that contains a blank cell.

=SUM(IF(COUNTIF(A1:D100,A1:D100)=0, "", 1/COUNTIF(A1:D100,A1:D100)))

Force A Global Recalculation


C ategory: Formulas | [Item URL]

Q. I find that sometimes my formulas do not get fully calculated. This often happens when
I use custom functions created with VBA.

Microsoft has acknow ledged some problems w ith the Excel calculation engine in some version
of Excel. In order to be assured that all of your formulas have been calculated, press Ctrl-Alt-F9
to force a complete recalculation.

This key combination w ill also update formulas that use custom VBA functions.

Summing Times That Exceed 24 Hours


C ategory: Formulas | [Item URL]

Q. I have a range of time values, but when I try to sum them, the total is never greater
than 24 hours.

W hen you add a range that contains time values, Excel ignores the hours that exceed 24. The
solution is to use a custom number format.

converted by Web2PDFConvert.com
1. Activate the cell that contains your total time
2. Choose Format, Cells.
3. In the Format Cells dialog box, click the Number tab.
4. Choose Custom from the Category list
5. Type [h]:mm into the box labeled Type.

Using brackets around the hour portion of the format string tells Excel to display hours that
exceed 24 hours.

Transforming Data With Formulas


C ategory: Formulas | [Item URL]

This tip describes a technique that should be in the arsenal of every Excel user. It describes
how to use formulas to transform data.

The figure below show s a simple example. The text in column A consists of low er case letters.
The goal is to transform these cells so they display "proper" case. This w ill be done by creating
formulas that use Excel's PROPER function.

The steps below are specific to this example. But they can easily be adapted to other types of
data transformations.

Creating the formulas


In this case, the formulas w ill go in column D. As you'll see, this is just a temporary location.
The formula results w ill eventually replace the names in column A.

1. Enter the follow ing formula in cell D2:


=PROPER(A2)
2. Copy the formula dow n the column to accommodate the data. In this case, the formula is
copied dow n to cell D11. The w orksheet now looks like this (the formula cells are selected,
so they appear highlighted).

Copying and pasting the formula cells


In this step, the formula cells are copied, and pasted as values -- overw riting the original data
in column A.

1. Select the formula cells. In this case, D2:D11.


2. Choose Edit - Copy
3. Select the first cell in the original data column (in this case, cell A2).
4. Choose Edit - Paste Special. This displays the Paste Special dialog box.
5. In the Paste Special dialog box, click the Value option button. This step is critical. It pastes
the results of the formulas -- not the formulas.

converted by Web2PDFConvert.com
6. Click OK.
At this point, the w orksheet looks like this:

Deleting the temporary formulas


The formulas in column D are no longer necessary, so you can delete them.

Creating A “Megaformula”
C ategory: Formulas | [Item URL]

This tip describes how to create w hat I call a "megaformula" -- a single formula that does the
w ork of several intermediate formulas.
An Example
The goal is to create a formula that returns the string of characters follow ing the final
occurrence of a specified character. For example, consider the text string below (w hich
happens to be a URL):

http://spreadsheetpage.com/index.php/tips
Excel does not provide a straightforw ard w ay to extract the characters follow ing the final slash
character (i.e., "tips") from this string. It is possible, how ever, do do so by using a number of
intermediate formulas. The figure below show s a multi-formula solution. The original text is in
cell A1. Formulas in A2:A6 are used to produce the desired result. The formulas are displayed
in column B.

Follow ing is a description of the intermediate formulas (w hich w ill eventually be combined into
a single formula).

1. Count the number of slash characters (Cell A2)


The formula in cell A2 returns the number of slash characters in cell A1. Excel doesn't
provide a direct w ay to count specific characters in a cell, so this formula is relatively
complex.
2. Replace the last slash character with an arbitrary character (Cell A3)
The formula in A3 uses the SUBSTITUTE function to replace the last slash character
(calculated in A2) w ith a new character. I chose CHAR(1) because there is little chance of
this character actually appearing in the original text string.
3. Get the position of the new character (Cell A4)
The formula in A4 uses the FIND function to determine the position of the new character.
4. Count the number of characters after the new character (Cell A5)
The formula in A5 subtracts the position of the new character from the length of the
original string. The result is the number of characters after the new character.
5. Get the text after the new character (Cell A6)
The formula in A6 uses the RIGHT function to extract the characters -- the end result.
Combining the Five Formulas Into One
Next, these five formulas w ill be combined into a single formula.

1. Activate the cell that displays the final result (in this case, cell A6). Notice that it contains a

converted by Web2PDFConvert.com
reference to cell A5.
2. Activate cell A5. Press F2 and select the formula text (but omit the initial equal sign), and
press Ctrl+C to copy the text. Press Esc.
3. Re-activate cell A6 and paste the copied text to replace the reference to cell A5. The
formula in A6 is now :
=RIGHT(A1,LEN(A1)-A4)
4. The formula contains a reference to cell A4, so activate A4 and copy the formula as text.
Then replace the reference to cell A4 w ith the copied formula text. The formula now looks
like this:
RIGHT(A1,LEN(A1)-FIND(CHAR(1),A3))
5. Replace the reference to cell A3 w ith the formula text from cell A3. The formula now looks
like this:
=RIGHT(A1,LEN(A1)-FIND(CHAR(1),SUBSTITUTE(A1,"/",CHAR(1),A2)))
6. Replace the reference to cell A2 w ith the formula text from cell A2. The formula now looks
like this:
=RIGHT(A1,LEN(A1)-FIND(CHAR(1),SUBSTITUTE(A1,"/",CHAR(1),LEN(A1)-LEN(SUBSTITUTE(A1,"/","")))))
The formula now refers only to cell A1, and the intermediate formula are no longer necessary.
This single formula does the w ork of five other formulas.

This general technique can be applied to other situations in w hich a final result uses several
intermediate formulas.

NOTE: You may think that using such a complex formula w ould cause the w orksheet to
calculate more slow ly. In fact, you may find just the opposite: Using a single formula in place of
multiple formulas may speed up recalculation. Any calculation speed differences, how ever, w ill
probably not be noticeable unless you have thousands of copies of the formula.

Caveat
Keep in mind that a complex formula such as this is virtually impossible to understand.
Therefore, use this type of formula only w hen you are absolutely certain that it w orks correctly
and you are sure that you w ill never need to modify it in the future. Better yet, keep a copy of
those intermediate formulas -- just in case.

Page 4 of 5 pages
[Previous page] [Next page]

© Copyright 2011, J-Walk & A ssociates, Inc.


This site is not affiliated with Microsoft Corporation.
Privacy Policy

converted by Web2PDFConvert.com

You might also like