6
J-Walk & Associates, Inc. Home  Books  Products  Tips  Downloads  Resources  Blog  Support Search Delete All Input Cells, But Keep The Formulas Category: Formulas | [Item URL] Your worksheet may be set up with formulas that operate on a number of input cells. Here's an easy way to clear all input values while keeping the formulas intact. Press F5 to display the Go To dial og bo x, and cli ck the Special button. In the Go To Speci al dialog, choose the Constants button and select Numbers. When you click OK, the nonformula numeric c ells will be selected. Pre ss Delete to de lete the values. The Go To Speci al dialog box has many oth er options for selecting cell s of a pa rtic ular type. Round Values To The Nearest Fraction Category: Formulas | [Item URL] Q. Is it possible to round a dollar amount to the nearest 25 cents? For example, if a number appears as $1 .65, I would like to convert it to $1.75. Excel's ROU ND() function seems to work only with whole numbers. Yes, you can us e Excel's ROUND( ) functi on to a chieve the roun ding you w ant. The following formul a, which ass umes tha t your value is in cell A1, will do the job for you. =ROUND(A1/.25,0)*.25 The formula divi des the o rigi nal value by .25 an d the n multi plies the result by .25. Y ou can, of course, use a simi lar formula to round value s to ot her fracti ons. For example, to round a dollar amount to th e nearest nickel, si mply subs titute .05 for each of the tw o occurrences of ".25" in the pre ceding formula. Avoid Error Displays In Formulas Category: Formulas | [Item URL] Sometimes a formul a may return an error message. Usually, you'll want to know wh en a formula error occurs. But now and then you may prefer to avoid the messages. You can do so by using a n IF() functi on to check for an e rror. 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 th e last a rgument of the IF() functi on. Like this: =IF(ISERROR( OriginalFormula ),"",OriginalFormula ) Change Cell Values Using Paste Special Category: Formulas | [Item URL] Q. I have a price list stored in a worksheet, and I need to increase all prices by 5 percent. Can I do this without reentering all the prices? Excel provi des tw o w ays to a ccompli sh this. The "traditional" technique go es s omething lik e this: 1. Insert or find a blank column near the prices. 2. In that column's fi rst cell, ente r a formula to multi ply the price in that row by 1.05. 3. Copy the formul a dow n the column. 4. Select and copy the entire column of f ormulas 5. Select the origi nal pri ces, and choose Edit, Paste Special. 6. In the Pas te Special di alog box, select Values to o verwrite the o rigi nal pri ces w ith the formulas' res ults. 7. And finall y, delete the column of formul as. The othe r, more e ffi ci ent a pproach also u ses the P aste Special di alog box. T o increase a range of values (prices, in this example) by 5 percent: 1. Enter 1.05 into an blank cell. Excel Tips Excel has a long history, and it continues to evolve and change. Consequently, the tips provided here do not necessarily apply to all versions of Excel. In particular , the user interface fo r Excel 2007 (and later), is vastly different from its predecessors. Therefore, the menu commands listed in older tips, wil l not correspond to the Excel 2007 (and later) user interface. All Tips List all tips, by category Browse all tips Browse Tips by Category General Fo rmatting Formulas Charts & Graphics Printing General VBA CommandBars & Menus UserForms VBA Functions Search for Tips Search:  Go Advanced Search Tip Books Needs tips? Here are two boo ks, with nothing but tips: Co ntains more than 200 useful tips and tricks for Excel 2007 | O ther Excel 2007 books | Amazon link: John Walkenbach's Favorite Exce l 2007 Tips & Tricks Co ntains more than 200 useful tips and tricks for Excel | Other Excel 2003 books | Amazon link: John Walkenbach's Favorite Excel Tips & Tricks converted by Web2PDFConvert.com

Excel Formula Tips 4

Embed Size (px)

Citation preview

8/6/2019 Excel Formula Tips 4

http://slidepdf.com/reader/full/excel-formula-tips-4 1/5

J-Walk & Associates, Inc. Home   Books   Products   Tips   Downloads   Resources   Blog   Support

Search

Delete All Input Cells, But Keep The Formulas

Category: Formulas | [Item URL]

Your worksheet may be set up with formulas that operate on a number of input cells. Here's an

easy way to clear all input values while keeping the formulas intact.

Press F5 to display the Go To dialog bo x, and click the Special button. In the Go To Special

dialog, choose the Constants button and select Numbers. When you click OK, the nonformula

numeric cells will be selected. Pre ss Delete to de lete the values. The Go To Special dialog box

has many other options for selecting cells of a pa rticular type.

Round Values To The Nearest Fraction

Category: Formulas | [Item URL]

Q. Is it possible to round a dollar amount to the nearest 25 cents? For example, if anumber appears as $1 .65, I would like to convert it to $1.75. Excel's ROUND() function

seems to work only with whole numbers.

Yes, you can use Excel's ROUND() function to a chieve the rounding you want. The following

formula, which ass umes tha t your value is in cell A1, will do the job for you.

=ROUND(A1/.25,0)*.25

The formula divides the o riginal value by .25 and then multiplies the result by .25. You can, of 

course, use a similar formula to round values to other fractions. For example, to round a dollar

amount to the nearest n ickel, simply subs titute .05 for each of the tw o occurrences of ".25" in

the pre ceding formula.

Avoid Error Displays In Formulas

Category: Formulas | [Item URL]

Sometimes a formula may return an e rror mess age . Usually, you'll want to know when a

formula error occurs. But now and then you may prefer to avoid the messages. You can do so

by using a n IF() function to check for an e rror.

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 a rgument of the IF() function. Like this:

=IF(ISERROR(OriginalFormula),"",OriginalFormula)

Change Cell Values Using Paste Special

Category: Formulas | [Item URL]

Q. I have a price list stored in a worksheet, and I need to increase all prices by 5 percent.

Can I do this without reentering all the prices?

Excel provides tw o ways to a ccomplish this. The "traditional" technique goes s omething like

this:

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

2. In that column's first cell, ente r a formula to multiply the price in that row by 1.05.

3. Copy the formula down the column.

4. Select and copy the entire column of formulas

5. Select the original prices, and choose Edit, Paste Special.

6. In the Pas te Special dialog box, select Values to overwrite the o riginal prices w ith the

formulas' results.

7. And finally, delete the column of formulas.

The othe r, more e fficient 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 an blank cell.

Excel TipsExcel has a long history, and it continues

to evolve and change. Consequently, the

tips provided here do not necessarily

apply to all versions of Excel.

In particular, the user interface fo r Excel

2007 (and later), is vastly different from

its predecessors. Therefore, the menu

commands listed in older tips, will not

correspond to the Excel 2007 (and later)

user interface.

All Tips

List all tips, by category

Browse all tips

Browse Tips by CategoryGeneral

Formatting

Formulas

Charts & Graphics

Printing

General VBA

CommandBars & Menus

UserForms

VBA Functions

Search for TipsSearch:

  Go

Advanced Search

Tip BooksNeeds tips? Here are two books, with

nothing but tips:

Contains more than 200 useful tips and

tricks for Excel 2007 | Other Excel 2007

books | Amazon link: John

Walkenbach's Favorite Exce l 2007

Tips & Tricks

Contains more than 200 useful tips andtricks for Excel | Other Excel 2003

books | Amazon link: John

Walkenbach's Favorite Excel Tips & 

Tricks

converted by Web2PDFConvert.com

8/6/2019 Excel Formula Tips 4

http://slidepdf.com/reader/full/excel-formula-tips-4 2/5

 

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

Category: 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 prope rties: locked and hidden. A locked cell can't be changed , and the

contents of a hidden cell don't appear in the formula bar when the cell is selected. By default,

every cell is locked and not hidden. But it's important to remember tha t these at tributes have

no e ffect unless the worksheet itself is protected.

First, to change the attributes, select the appropriate cell or range and then choose Format,

Cells. In the Format Ce lls dialog box, click the P rotection tab and se lect Locked or Hidden (or

both). Unlock cells that accept use r input, and lock formula and othe r cells that s hould stay

unchanged (such as titles). To prevent othe rs from seeing your formulas, lock and hide the

formula cells: The resu lts 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 Co ntents box is checked. You can enter a password to

prevent others from unprotecting the sheet. Locked cells in a protected sheet cannot be

edited, and other wo rksheet changes are disabled. For example, no one can insert rows or

columns, change column width, or create embedded charts.

NOTE: Keep in mind tha t it is very easy to break the pa sswo rd for a protected sheet. If you

are looking for rea l security, this is not the solution.

Counting Distinct Entries In A Range

Category: 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 hun ting for a formula that, given the range tha t contains

the values 100, 99, 98, 100, 98, 100, 98, would return 3. In other words, this range contains

three different values, some o f 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))

When you enter this formula, you must press Ctrl-Shift-Enter. Pressing only Enter will give you

the w rong resu lt. Excel will place brackets around the formula to remind you that you've

created a n array formula.

The preceding formula works fine in many cases, but it will return an error if the range conta ins

any blank cells. The formula below (also an a rray formula, so input it w ith Ctrl-Shift-Enter ) is

more complex, but it w ill handle a range that conta ins a blank cell.

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

Force A Global Recalculation

Category: 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 acknowledged some problems with 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 upda te formulas that use custom VBA functions.

Summing Times That Exceed 24 Hours

Category: 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.

When you add a range that contains time values, Excel ignores the hours that e xceed 24. The

solution is to use a custom number format.

converted by Web2PDFConvert.com

8/6/2019 Excel Formula Tips 4

http://slidepdf.com/reader/full/excel-formula-tips-4 3/5

1. Activate the cell that contains your tota l time

2. Choose Format, Cells.

3. In the Format Ce lls 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

Category: Formulas | [Item URL]

This tip des cribes a technique that should be in the arsenal of every Excel user. It describes

how to use formulas to transform data.

The figure below shows a simple example. The text in column A consists of lower case letters.

The goa l is to trans form these cells so the y display "proper" case. This will be done by creating

formulas tha t use Excel's PROPER function.

The steps below are specific to this example. But they can ea sily be a dapted to other types o f 

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 eventua lly replace the names in column A.

1. Enter the follow ing formula in cell D2:

=PROPER(A2)

2. Copy the formula down the column to accommodate the data. In this case, the formula is

copied down to cell D11. The worksheet 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 pa sted as values -- overwriting 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 - Pas te Special. This displays the Pas te Special dialog box.

5. In the Pa ste Spe cial dialog box, click the Value op tion button. This step is critical. It paste s

the res ults of the formulas -- not the formulas.

converted by Web2PDFConvert.com

8/6/2019 Excel Formula Tips 4

http://slidepdf.com/reader/full/excel-formula-tips-4 4/5

6. Click OK.

At this point, the worksheet looks like this:

Deleting the temporary formulas

The formulas in column D are no longer necessa ry, so you can de lete them.

Creating A “Megaformula”

Category: Formulas | [Item URL]

This tip des cribes how to create what I call a "megaformula" -- a single formula that does the

work of several intermediate formulas.

An Example

The goal is to create a formula that returns the string of characters following the final

occurrence of a specified chara cter. For example, consider the te xt string below (which

happens to be a URL):

http://spreadsheetpage.com/index.php/tips

Excel does not provide a straightforward way to extract the characters following the final slash

character (i.e., "tips") from this string. It is po ssible, however, do do so by using a number of 

intermediate formulas. The figure be low show s a multi-formula so lution. The o riginal text is in

cell A1. Formulas in A2:A6 are used to produce the des ired result. The formulas are displayed

in column B.

Following is a de scription of the intermediate formulas (which will even tually be combined into

a s ingle 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 way to count specific characters in a cell, so th is 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) with a new character. I chose CHAR(1) because there is little chance o f 

this character actually appearing in the original text s tring.

3. Get the position of the new character (Cell A4)

The formula in A4 uses the FIND function to dete rmine 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 res ult 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 chara cters -- the end result.

Combining the Five Formulas Into One

Next, these five formulas will be combined into a s ingle formula.

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

converted by Web2PDFConvert.com

8/6/2019 Excel Formula Tips 4

http://slidepdf.com/reader/full/excel-formula-tips-4 5/5

reference to cell A5.

2. Activate cell A5. Press F2 and s elect 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 pas te the cop ied text to replace the re ference 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 with the copied formula text. The formula now looks

like this:

RIGHT(A1,LEN(A1)-FIND(CHAR(1),A3))

5. Replace the re ference to ce ll A3 with 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 re ference to ce ll A2 with 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 longe r necessa ry.

This single formula does the w ork of five othe r formulas.

This general technique can be applied to other situations in which a final result uses several

intermediate formulas.

NOTE: You may think that using such a complex formula would cause the worksheet to

calculate more s lowly. In fact, you may find just the opposite: Using a s ingle formula in place of 

multiple formulas may spee d up recalculation. Any calculation speed differences, how ever, will

probably not be noticeable unless you have thousands o f copies of the formula.

Caveat

Keep in mind tha t a complex formula such as this is virtually imposs ible to understand.

Therefore, use this type of formula only when you are absolutely certain that it works correctly

and you are sure that you will 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 & Assoc iates, Inc.

This site is not affiliated with Microsoft Corporation.

Privacy Policy

t d b W b2PDFC t