Excel User Tips - Misscellaneous

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Excel User Tips

Changing the Text Size in Excel's Help


Excel 2000 and later use HTML Help to display help topics. If you find that the text
size is too small (or too large), you can easily change it.

• If you have a wheel mouse, press Ctl and spin the wheel to change the text size.
Make sure that the text window, not the contents window, is active.
• If you don't have a wheel mouse, activate Internet Explorer and use the View -
Text Size command to change the size of the text. Close Excel help and re-open
it and it will display the text size you specified.

Increase the number of rows or columns?


Q. How can I increase the number of rows or columns in a worksheet?

In Excel, every workbook has 256 columns and 65,526 rows. Versions prior to Excel 97
have only 16,384. These values are fixed and cannot be changed. Despite what must
amount to thousands of requests, Microsoft refuses to increase the size of a worksheet.

If you need more rows, you might want to consider using a database (such as Access)
or another spreadsheet (Quattro Pro can handle a million rows) for data storage. In
most cases, you probably don't need to work with all of your data at once. You'll usually
need only a subset of your data. You can use Excel's Data, Get External Data command
to query the database and bring in only the records you need.

Forget your password?


Q. I saved my workbook with a password, but Excel doesn't recognize it and
won't let me open the file. Am I out of luck?

First, remember that passwords are case-sensitive. So if you originally entered your
password as Xyzzy, typing xyzzy won't work.

If you know you're entering the password correctly, then it's time to start looking for a
password recovery utility. Several utilities exist, and a partial list is available here.

By the way, the fact that these products exist might raise some alarms for the security-
minded. Bottom line? Excel password protection isn't as secure as you might expect.

Close all workbooks quickly


If you find yourself with many workbooks open at the same time, you may be interested
in a "hidden" command that will close all workbooks in one fell swoop. The trick is to
press Shift while you click the File menu. When you do so, the Close command turns
into the Close All command. When you select this menu item, Excel will close all of the
currently open workbooks. If any of them have not been saved, you'll get the standard
prompt asking if you want to save your workbooks.

Resize Excel's sheet tabs


If your eyesight isn't what it used to be, you may want to increase the size of the sheet
tabs displayed in your Excel workbooks.

Excel User Tips_Misscellaneous


Page 1 of 13
This parameter is determined by a Windows system-wide setting. To change it, select
Start, Settings, Control Panel and double-click Display. In the Display Properties dialog
box, click the Appearance tab, and choose Scrollbar from the Item list. Adjust the sheet
tabs until they're the size you want. Be aware that this setting affects the scroll bars in
all your applications.

Using a workspace file


If you usually work with a number of workbooks simultaneously, you might like the idea
of opening all of your workbooks exactly where you left off the last time you closed
Excel.

If so, you need to create a workspace file. Before you quit for the day, select Files, Save
Workspace and specify a file name. To pick up where you left off in the last session,
reopen the workspace file: Use File, Open and choose the workspace file (it'll have an
.xlw extension).

Note: A workspace file contains only configuration information, not the actual
workbooks and worksheets. Therefore, you can't simply copy the workspace file -- you'll
need the workbook files, too.

Importing a text file into a worksheet


Excel users have long envied 1-2-3's ability to insert the contents of a text file into a
worksheet. Until Excel 2000, all versions of Excel required you to open the text file
separately, then copy and paste the data to your worksheet.

Excel 2000 (and later) makes the process much easier. You might expect to see this
feature on the File menu, but instead you select Data, Get External Data, Import Text
File. This command calls up a dialog box in which you select a text file, whereupon the
Text Import Wizard lets you specify how Excel should import the data. Finally, in the
Import Data dialog box, you indicate the desired worksheet destination.

Excel imports the text file as a database query, which you can update if the data in the
text file changes (select Data, Refresh Data to do so). To import the file as static data,
click Properties in the Import Data dialog, and remove the check mark from the "Save
query definition" box.

Removing or avoiding automatic hyperlinks


You may have discovered that Excel 2000 supports automatic cell hyperlinks. Whenever
you type something that resembles a URL or an e-mail address into a cell, this feature
automatically converts the text into a clickable hyperlink. But what if you don't want to
create a hyperlink?

Excel User Tips_Misscellaneous


Page 2 of 13
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

Surprisingly, Excel doesn't provide a direct way to remove all hyperlinks on a


worksheet. In fact, the only way to accomplish this is one cell at a time: Activate the
cell that contains the hyperlink, right-click, and then select Hyperlink, Remove
Hyperlink. Unfortunately, this command is available only when you have selected a
single cell. To quickly deactivate all hyperlinks, you need to use a macro.

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
End Sub
When you execute the ZapHyperlinks macro, all hyperlinks on the active sheet are
deleted and replaced with normal text.

Making a worksheet very hidden


You can use Excel's Format, Sheet, Hide to hide an entire worksheet. But unless you
password-protect the workbook structure, anyone can select Format, Sheet, Unhide to
see the hidden sheet.

If you use Excel 97 or later, here's another option:

1. Press Alt-F11 to display the Visual Basic Editor


2. in the Project window, double-click Microsoft Excel Objects and select the sheet
to hide.
3. Press F4 to display the Property box
4. Set the sheet's Visible property to xlSheetVeryHidden.
To unhide the sheet, repeat these step, but set the Visible property to xlSheetVisible.

Copy Page Setup settings to other sheets


Each Excel sheet has its own print setup options (orientation, margins, headers and
footers, and so on). These options are specified in the Page Setup dialog box, which you
access using the File, Page Setup command.

When you add a new sheet to a workbook, it contains the default page setup setting.
Here's an easy way to transfer the settings from one worksheet to additional
worksheets:

1. Activate the sheet that contains the desired setup info. This is the "source"
sheet.
2. Select the "target" sheets. Press Ctrl and click the sheet tabs of the sheets you
want to update with the settings from the source sheet.
3. Select File, Page Setup and click OK.

Excel User Tips_Misscellaneous


Page 3 of 13
The Page Setup settings of the source sheet will be transferred to all of the target
sheets.

Override Excel's Text Import Wizard


If you import text files into Excel, you've undoubtedly encountered the Text Import
Wizard, which guides you through parsing the text.

If the files you import are always parsed correctly, you may prefer to bypass this wizard
and accept the defaults. To do so:

1. Select File, Open

2. Locate the file to be imported

3. Hold down Shift while you click Open

Note: When you import a file with a .csv extension, the Text Import Wizard won't kick
in. To override this default, you need to change the file's extension from .csv to .txt.

Navigating Excel's sheets


Every Excel user knows that you can activate a different sheet in a workbook by clicking
its sheet tab. Most users also know that you can press Ctrl-Page Up to activate the
previous sheet, and Ctrl-Page Down to activate the next sheet.

But if your workbook contains many sheets, and not all of the sheets' tabs fit on the
screen, you may find it tedious to scroll through the tabs or use the keyboard to
activate a distant sheet.

Here's a little-known trick that will allow you to bypass repeated scrolling or typing:
Display a pop-up list of sheet names by right-clicking one of the arrows to the left of the
sheet tabs that are located at the bottom of the worksheet window (see the figure
below). Select a sheet from the list, and you're there in a flash.

Excel User Tips_Misscellaneous


Page 4 of 13
Comparing Two Lists With Conditional Formatting
Excel's Conditional Formatting feature has many uses. Suppose you need to compare
two lists, and identify the items that are different. The figure below shows an example.
These lists happen to contain text, but this technique also works with numeric data.

The first list is in A2:B19, and this range is named OldList. The second list is in D2:E19,
and the range is named NewList. The ranges were named using the Insert - Name -
Define command. Naming the ranges is not necessary, but it makes them easier to
work with.

As you can see, items in OldList that do not appear in NewList are highlighted with a
yellow background. Items in NewList that do not appear in OldList are highlighted with a
green background. These colors are the result of Conditional Formatting.

How to do it
1. Start by selecting the OldList range.
2. Choose Format - Conditional Formatting
3. In the Conditional Formatting dialog box, use the drop-down list to choose
Formula is.
4. Enter this formula:

=COUNTIF(NewList,A2)=0
5. Click the Format button and specify the formatting to apply when the condition
is true (a yellow background in this example).
6. Click OK

Excel User Tips_Misscellaneous


Page 5 of 13
The cells in the NewList range will use a similar conditional formatting formula.

1. Select the NewList range.


2. Choose Format - Conditional Formatting
3. In the Conditional Formatting dialog box, use the drop-down list to choose
Formula is.
4. Enter this formula:

=COUNTIF(OldList,D2)=0
5. Click the Format button and specify the formatting to apply when the condition
is true (a green background in this example).
6. Click OK
Both of these conditional formatting formulas use the COUNTIF function. This function
counts the number of times a particular value appears in a range. If the formula returns
0, it means that the item does not appear in the range. Therefore, the conditional
formatting kicks in and the cell's background color is changed.

The cell reference in the COUNTIF function should always be the upper left cell of the
selected range.

Making an exact copy of a range of formulas


Assume that A1:D10 on Sheet1 has a range of cells that contain formulas. Furthermore,
assume that you want to make an exact copy of these formulas, beginning in cell A11
on Sheet1. By "exact," we mean a perfect replica -- the original cell references should
not change.

If the formulas contain only absolute cell references, it's a piece of cake. Just use the
standard copy/paste commands. But if the formulas contain relative or mixed
references, the standard copy/paste technique won't work because the relative and
mixed references will be adjusted when the range is pasted.

If you're a VBA programmer, you can simply execute the following code:
With Sheets("Sheet1")
.Range("A11:D20").Formula = .Range("A1:D10").Formula
End With
Here's a procedure to accomplish this task without using VBA. (contributed by Bob Umlas):

1. Select the source range (A1:D10 in this example).


2. Group the source sheet with another empty sheet (say Sheet2). To do this,
press Ctrl while you click the sheet tab for Sheet2
3. Select Edit - Fill - Across worksheets (choose the All option in the dialog box).
4. Ungroup the sheets (click the sheet tab for Sheet2)

Excel User Tips_Misscellaneous


Page 6 of 13
5. In Sheet2, the copied range will be selected. Choose Edit - Cut.
6. Activate cell A11 (in Sheet2) and press Enter to paste the cut cells. A11.D20 will
be selected.
7. Re-group the sheets. Press Ctl and click the sheet tab for Sheet1
8. Once again, use Edit - Fill - Across worksheets.
9. Activate Sheet1, and you'll find that A11:D20 contains an exact replica of the
formulas in A1:D10.
Note: This sounds more complicated than it actually is.

Restrict cursor movement to unprotected cells


Q. The formulas in my worksheet use values in several input cells. I've
unlocked the input cells and protected the sheet so the user can't change the
formulas. Can I set things up so the cell cursor moves only to the input cells?

Yes. You've already unlocked your input cells and ensured that all other cells are locked.
By default all cells are locked, but you can change that by using the Protection tab of
the Format Cells dialog box. Select the cells to be changed and choose Format, Cells. In
this case, the input cells are unlocked and all other cells are locked.

Protect the worksheet in Excel 97 by using Worksheet, Protect or Tools, Protection,


Protect Sheet (you can specify a password to keep others from "unprotecting" the
sheet). Once the sheet is protected, press Tab to move the cell pointer to the next
unlocked cell.

This does not prevent the user from selecting unlocked cells using the cursor keys. To
make those cells unselectable, change the worksheet's EnableSelection property. Select
View, Toolbars, Control Toolbox to display the Control Toolbox toolbar. Click the
Properties button to display the Properties box for the worksheet, then click the cell
labeled "xlNoRestrictions" and use the drop-down list to change the EnableSelection
property to xlUnlockedCells. Close the Properties box. As long as the worksheet is
protected, users cannot select the locked cells on the worksheet.

This procedure does not save the EnableSelection property setting with the workbook.
To create a simple macro that turns this setting on when the workbook is opened, press
Alt-F11 to activate the Visual Basic Editor. Locate your workbook name in the Project
window, and double-click it to expand its listing. Then double-click the item labeled
ThisWorkbook and enter the following VBA code:
Private Sub Workbook_Open()
Worksheets("Sheet1").EnableSelection = xlUnlockedCells
End Sub
This macro executes whenever the workbook is opened, and sets the EnableSelection
property of Sheet1 to xlUnlockedCells. The technique can be circumvented by changing
the EnableSelection property to its default value (xlNoRestrictions). Few users know
about this dodge, however.

Protecting cells, sheets, workbooks, and files


Excel offers many ways to protect your data. But understanding the differences between
the methods and the limitations of each of them can be daunting. Here's a quick review
of four protection options in Excel 97 and later, plus explanations of how to use them.

Excel User Tips_Misscellaneous


Page 7 of 13
Note: These protection features aren't foolproof. Password-cracking utilities exist, and
anyone who wants to defeat your protection badly enough probably can.

Cell protection
Every cell has two 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 when the cell is
selected. By default, every cell is locked and not hidden. Locked and hidden attributes
have no effect unless the worksheet is protected.

To change these attributes, select the appropriate cell or a range and then choose
Format, Cells. In the Format Cells dialog box, click the Protection tab and select Locked
or Hidden. Unlock cells that accept user input, and lock formula cells 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 will be visible, but the
formulas will not.

To protect a sheet, choose Tools, Protection, Protect Sheet to bring up the Protect Sheet
dialog, and make sure Contents 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 worksheet changes are disabled. For example, no one can insert rows or columns,
change column width, or create embedded charts.

Note: Excel 2002 offers additional options regarding what the user can and cannot do
when a sheet is protected. For example, you can protect a sheet and still allow sorting
and autofiltering.

Workbook window protection


The Tools, Protection, Protect Workbook command enables you to protect a workbook
so no one can add or delete sheets or resize or move the workbook window.

Workbook file protection


Here's how to save a workbook in such a way that you must supply a password to open
or modify it:

• In Excel 97, select File, Save As to display the Save As dialog box; then click
Options in that box to call up the Save Options dialog.

• In Excel 2000 and Excel 2002, select Tools, General Options when the Save As
dialog box appears. If you enter a password in the "Password to open" field, the
user must provide the correct password to open the file. If you enter a password
in the "Password to modify" field, the user must give the right password to make
changes to the file. Without the correct password, the file opens in read-only
mode.

Note: Excel 2002 also lets you specify the type of encryption, if any, that will be used.
Access this feature by clicking the Advanced button in the Save Options dialog box.

VBA project protection


If your workbook contains VBA macros, you can use these to prohibit others from
viewing or modifying them. Press Alt-F11 to activate the VB Editor window, and select
your project from the Project window. Choose Tools, VBA Project Properties. Click the
Protection tab, place a check mark next to "Lock project for viewing," and enter the
password twice. Click OK and save your workbook.

Excel User Tips_Misscellaneous


Page 8 of 13
Changing the number of sheets in a new workbook
By default, each new Excel workbook begins life with three worksheets. You can, of
course, add more sheets to the workbook or delete sheets you don't need. The unused
sheets don't occupy additional memory or increase file size, but I generally don't like
them in my workbooks.

A better approach is to change the default. Select Tools, Options and click General in
the Options dialog box. Then change the setting for "Sheets in new workbook". Now all
new workbooks will have the number of sheets you specified.

I recommend that you change this setting to 1.

Sharing AutoCorrect shortcuts


Q. I've set up approximately 200 Excel AutoCorrect shortcuts that represent
various products and services offered by my company. What's the best way to
transfer these shortcuts to other systems so that my coworkers can use them?

AutoCorrect, which debuted in Excel 95, can correct common spelling errors on the fly.
As many users of Excel have discovered, you can also assign "shorthand shortcuts" that
expand to a longer sequence of characters. For example, you may define "awc" as an
AutoCorrect shortcut for "Amalgamated Widget Corporation of America." When you type
awc into a cell, Excel will then replace it with the associated text string. You define and
manage your shortcuts by using the Tools, AutoCorrect command.

Excel and all other Microsoft Office applications store AutoCorrect shortcuts in a single
*.acl file in your Windows folder (the exact file name will vary). So changes you make
from Excel, say, will be available in Word. However, there's no tool for manually editing
the binary *.acl file and moving such a file from one system to another will invalidate
your existing entries. The solution is to use a VBA macro to create the shortcuts.

Start Excel with a new workbook with one sheet, and then enter your shortcuts and
their associated text into columns A and B, respectively (as in the figure below). Enter
as many as you like, beginning in row 1, and don't include any blank rows between the
entries. Save and name this worksheet.

Select Tools, Macro, Macros to display the Macros dialog box. Type CreateShortcuts in
the Macro Name field and click Create. Then enter the following macro into the VBA
module, and press Alt-F11 to return to Excel.
Sub CreateShortcuts()
ItemCount = Application.CountA(Range("Sheet1!A:A"))
For Row = 1 To ItemCount

Excel User Tips_Misscellaneous


Page 9 of 13
ShortText = Cells(Row, 1)
LongText = Cells(Row, 2)
Application.AutoCorrect.AddReplacement ShortText, LongText
Next Row
End Sub
Save the workbook and distribute it to your coworkers. To add the AutoCorrect
shortcuts, open the workbook, select Tool, Macro, Macros, and then execute the
CreateShortcuts macro. Be aware that existing shortcuts with the same name will be
overwritten without warning.

Locate phantom links in a workbook


Q. Whenever I open a particular Excel workbook, I get a message asking if I
want to update the links. I've examined every formula in the workbook, and I
am absolutely certain that the workbook contains no links to any other file.
What can I do to convince Excel that the workbook has no links?

You've encountered the infamous "phantom link" phenomenon. I've never known Excel
to be wrong about identifying links, so there's an excellent chance that your workbook
does contain one or more links -- but they are probably not formula links.

Follow these steps to identify and eradicate any links in a workbook.

1. Select Edit, Links. In many cases, this command may not be available. If it is
available, the Links dialog box will tell you the name of the source file for the
link. Click the Change Source button and change the link so it refers to the
active file.
2. Select Insert, Name, Define. Scroll through the list of names in the Define Name
dialog box and examine the Refers to box (see the figure below). If a name
refers to another workbook or contains an erroneous reference such as #REF!,
delete the name. This is, by far, the most common cause of phantom links
3. If you have a chart in your workbook, click on each data series in the chart and
examine the SERIES formula displayed in the formula bar. If the SERIES formula
refers to another workbook, you've identified your link. To eliminate the link
move or copy the chart's data into the current workbook and recreate your
chart.
4. If your workbook contains any custom dialog sheets, select each object in each
dialog sheet and examine the formula bar. If any object contains a reference to
another workbook, edit or delete the reference.
Next, save your workbook and then re-open it. It should open up without asking you to
update the links.

Excel User Tips_Misscellaneous


Page 10 of 13
Displaying AutoFilter criteria
Excel's AutoFilter feature definitely ranks right up there when it comes to handy tools.
This feature, which you access with the Data, Filter, AutoFilter command, works with a
range of cells set up as a database or list. When AutoFiltering is turned on, the row
headers display drop-down arrows that let you specify criteria (such as "Age greater
than 30"). Rows that don't match your criteria are hidden, but they are redisplayed
when you turn off AutoFiltering.

One problem with AutoFiltering is that you can't tell which criteria are in effect. Stephen
Bullen developed a custom VBA worksheet function that displays the current AutoFilter
criteria in a cell. The instructions that follow are for Excel 97 or later.

Press Alt+F11 and insert a new module for the active workbook. Then enter the VBA
code for the FilterCriteria shown below.
Function FilterCriteria(Rng As Range) As String
'By Stephen Bullen
Dim Filter As String
Filter = ""
On Error GoTo Finish
With Rng.Parent.AutoFilter
If Intersect(Rng, .Range) Is Nothing Then GoTo Finish
With .Filters(Rng.Column - .Range.Column + 1)
If Not .On Then GoTo Finish
Filter = .Criteria1
Select Case .Operator
Case xlAnd
Filter = Filter & " AND " & .Criteria2
Case xlOr
Filter = Filter & " OR " & .Criteria2
End Select
End With
End With
Finish:
FilterCriteria = Filter
End Function
After you've entered the VBA code, you can use the function in your formulas. The
single-cell argument for the FilterCriteria function can refer to any cell within the column

Excel User Tips_Misscellaneous


Page 11 of 13
of interest. The formula will return the current AutoFilter criteria (if any) for the
specified column. When you turn AutoFiltering off, the formulas don't display anything.

The figure below shows the FilterCriteria in action. The function is used in the cells in
row 1. For example, cell A1 contains this formula:
=FilterCriteria(A3)
As you can see, the list is currently filtered to show rows in which column A contains
January, column C contains a code of A or B, and column D contains a value greater
than 125 (column B is not filtered, so the formula in cell B1 displays nothing). The rows
that don't match these criteria are hidden.

Share your spreadsheets on the Web


If you use Excel 2000 or later, it's relatively easy to save a workbook in HTML as a web
document. In fact, Excel supports two types: static documents and interactive
documents

Creating a static web document


After creating your workbook, use the File, Save as Web Page command. Specify what
you want to save (a single worksheet or the entire workbook) and click the Save button.
The result will be an HTML document and, possibly, a directory containing ancillary files;
the number of such files varies with the complexity of your workbook. These files
contain information, such as graphics and macros, that can't be stored in standard
HTML format. When you post the HTML file on a Web server, you must include the files
in the associated directory. You'll find that the HTML file survives "round-tripping." In
other words, if you reopen the HTML file in Excel 2000, every element will be intact.

Creating an interactive web document


Alternately, you may save your workbook (single sheet only) in HTML format with
"interactivity." When you open the HTML file in a compatible übrowser (IE 4.01 or later,
not Netscape Navigator), you can interact with the Web page: enter data, recalculate
formulas, update charts and pivot tables, and so on. Before you get too excited,
however, realize that this feature has some serious limitations. Many common

Excel User Tips_Misscellaneous


Page 12 of 13
formatting options are not retained, and features like array formulas, macros, and
outlining aren't supported.

View a sample interactive spreadsheet


The figure below shows a simple interactive HTML document I created. This worksheet
calculates the dates for various U.S. holidays, using the year entered in cell C3. I used
the File, Save as Web Page command to save the workbook in HTML format. In the
Save As dialog box, I checked the box labeled Add interactivity.

To view the actual document, Click here. The interactive document will appear in a
new browser window.

You can change the year in cell C3 and the sheet will update automatically. The sheet
isn't protected,o you can even examine the formulas. Because there's no formula bar,
you will have to press F2 to view the formula in the active cell.

To view an interactive Excel file, you need Internet Explorer 4.01 or later, and Microsoft
Office Web Components (included with most versions of Office 2000 and later) must be
installed on your system.

Note: If you have Excel 2000 installed on your system and you receive an error
message when attempting to view an interactive spreadsheet on the Web, check your
version of the software. For reasons known only to Microsoft, the Office Web
components aren't included with the Small Business Edition of Office 2000 or with the
stand-alone version of Excel 2000. In other words, your copy of Excel 2000 may be
lacking one of the key selling points of the product. According to Microsoft, you can
legally install the Office Web Components if you own Office 2000 Small Business Edition
and if someone in your organization has a license for Microsoft Office 2000 Premium,
Professional, or Standard, or Microsoft Access 2000. If you have only the stand-alone
version of Excel, you cannot install the Web Components.

Excel User Tips_Misscellaneous


Page 13 of 13

You might also like