So far, you've learned how to create a basic worksheet with a table of data. That's great for getting started, but as power users, professional accountants, and other Excel jockeys quickly learn, some of the most compelling reasons to use Excel involve multiple tables that share information and interact with each other.
For example, say you want to track the performance of your company: you create one table summarizing your firm's yearly sales, another listing expenses, and a third analyzing profitability and making predictions for the coming year. If you create these tables in different spreadsheet files, you must copy shared information from one location to another, all without misplacing a number or making a mistake. And what's worse, with data scattered in multiple places, you're missing the chance to use some of Excel's niftiest charting and analytical tools. But cramming a bunch of tables onto the same worksheet page isn't the solution. Not only are you likely to lose your spot in the avalanche of data, you'll also face a host of formatting and cell management problems.
Fortunately, a better solution exists. Excel lets you create spreadsheets with multiple pages of data, each of which can conveniently exchange information with other pages. Each page is called a worksheet, and a collection of one or more worksheets is called a workbook (which is also sometimes called a spreadsheet file).
In this chapter, you'll learn how to manage the worksheets in a workbook. You'll also take a look at Find and Replace, an Excel tool for digging through worksheets in search of specific data.
Many workbooks contain more than one table of information. For example, you might have a list of your bank account balances and a list of items repossessed from your home in the same financial planning spreadsheet. You might find it a bit challenging to arrange these different tables. You could stack them (Figure 4-1) or place them side by side (Figure 4-2), but neither solution is perfect.
Figure 4-1. Stacking tables on top of each other is usually a bad idea. If you need to add more data to the first table, then you must move the second table. You'll also have trouble properly resizing or formatting columns because each column contains data from two different tables.
Figure 4-2. You're somewhat better off putting tables side by side, separated by a blank column, than you are stacking them, but this method can create problems if you need to add more columns to the first table. It also makes for a lot of side-to-side scrolling.
Most Excel masters agree that the best way to arrange different tables of information is to use separate worksheets for each table. When you create a new workbook, Excel automatically fills it with three blank worksheets named Sheet1, Sheet2, and Sheet3. Often, you'll work exclusively with the first worksheet (Sheet1), and not even realize that you have two more blank worksheets to play with—not to mention the ability to add plenty more.
To move from one worksheet to another, you have a few choices:
Click the worksheet tabs at the bottom of Excel's grid window (just above the status bar), as shown in Figure 4-3.
Press Ctrl+Page Down to move to the next worksheet. For example, if you're currently in Sheet1, this key sequence jumps you to Sheet2.
Press Ctrl+Page Up to move to the previous worksheet. For example, if you're currently in Sheet2, this key sequence takes you back to Sheet1.
Figure 4-3. Worksheets provide a good way to organize multiple tables of data. To move from one worksheet to another, click the appropriate Worksheet tab at the bottom of the grid. Each worksheet contains a fresh grid of cells—from A1 all the way to XFD1048576.
Excel keeps track of the active cell in each worksheet. That means if you're in cell B9 in Sheet1, and then move to Sheet2, when you jump back to Sheet1 you'll automatically return to cell B9.
Excel includes some interesting viewing features that let you look at two different worksheets at the same time, even if these worksheets are in the same workbook. You'll learn more about custom views in Chapter 7.
When you start a fresh workbook in Excel, you automatically get three blank worksheets in it. You can easily add more worksheets. Just click the Insert Worksheet button, which appears immediately to the right of your last worksheet tab (Figure 4-4). You can also use the Home→Cells→Insert→Insert Sheet command, which works the same way but inserts a new worksheet immediately to the left of the current worksheet. (Don't panic: Naming and Rearranging Worksheets shows how you can rearrange worksheets after the fact.)
Figure 4-4. Every time you click the Insert Worksheet button, Excel inserts a new worksheet after your existing worksheets and assigns it a new name. For example, if you start with the standard Sheet1, Sheet2, and Sheet3 and click the Insert Worksheet button, then Excel adds a new worksheet named—you guessed it—Sheet4.
If you continue adding worksheets, you'll eventually find that all the worksheet tabs won't fit at the bottom of your workbook window. If you run out of space, you need to use the scroll buttons (which are immediately to the left of the worksheet tabs) to scroll through the list of worksheets. Figure 4-5 shows the scroll buttons.
Figure 4-5. Using the scroll buttons, you can move between worksheets one at a time or jump straight to the first or last tab. These scroll buttons control only which tabs you see—you still need to click the appropriate tab to move to the worksheet you want to work on.
If you have a huge number of worksheets and they don't all fit in the strip of worksheet tabs, there's an easier way to jump around. Right-click the scroll buttons to pop up a list with all your worksheets. You can then move to the worksheet you want by clicking it in the list.
Removing a worksheet is just as easy as adding one. Simply move to the worksheet you want to get rid of, and then choose Home→Cells→Delete→Delete Sheet (you can also right-click a worksheet tab, and then choose Delete). Excel won't complain if you ask it to remove a blank worksheet, but if you try to remove a sheet that contains any data, it presents a warning message asking for your confirmation. Also, if you're down to one last worksheet, Excel won't let you remove it. Doing so would create a tough existential dilemma for Excel—a workbook that holds no worksheets—so the program prevents you from taking this step.
Excel starts you off with three worksheets for each workbook, but changing this setting's easy. You can configure Excel to start with fewer worksheets (as few as one), or many more (up to 255). Select File→Options, and then choose the General section. Under the heading "When creating new workbooks", change the number in the "Include this many sheets" box, and then click OK. This setting takes effect the next time you create a new workbook.
Although you're limited to 255 sheets in a new workbook, Excel doesn't limit how many worksheets you can add after you've created a workbook. The only factor that ultimately limits the number of worksheets your workbook can hold is your computer's memory. However, modern-day PCs can easily handle even the most ridiculously large, worksheet-stuffed workbook.
When you hide a worksheet, its tab disappears, but the worksheet itself remains part of your spreadsheet file, available whenever you choose to unhide it. Hidden worksheets also don't appear on printouts. To hide a worksheet, right-click the worksheet tab, and then choose Hide. (Or, for a more long-winded approach, choose Home→Cells→Format→Hide & Unhide→Hide Sheet.)
To redisplay a hidden worksheet, right-click any worksheet tab, and then choose Unhide. The Unhide dialog box appears along with a list of all hidden sheets, as shown in Figure 4-6. Select a sheet from the list, and then click OK to unhide it. (Once again, the ribbon can get you the same window—just point yourself to Home→Cells→Format→Hide & Unhide→Unhide Sheet.)
The standard names Excel assigns to new worksheets—Sheet1, Sheet2, Sheet3, and so on—aren't very helpful for identifying what they contain. And they become even less helpful if you start adding new worksheets, since the new sheet numbers don't necessarily indicate the position of the sheets, just the order in which you created them.
For example, if you're on Sheet 3 and you add a new worksheet (by choosing Home→Cells→Insert→Insert Sheet), then the worksheet tabs read: Sheet1, Sheet2, Sheet4, Sheet3. (That's because the Insert Sheet command inserts the new sheet just before your current sheet.) Excel doesn't expect you to stick with these auto-generated names. Instead, you can rename them by right-clicking the worksheet tab and selecting Rename, or just double-click the sheet name. Either way, Excel highlights the worksheet tab, and you can type a new name directly onto the tab. Figure 4-7 shows worksheet tabs with better names.
Figure 4-7. Worksheet names can be up to 31 characters long and can include letters, numbers, some symbols, and spaces. Remember, though, the longer the worksheet name, the fewer worksheet tabs you'll be able to see at once, and the more you'll need to rely on the scroll buttons to the left of the worksheet tabs. For convenience's sake, try to keep your names brief by using titles like Sales04, Purchases, and Jet_Mileage.
Excel has a small set of reserved names that you can never use. To witness this problem, try to create a worksheet named History. Excel doesn't let you, because it uses the History worksheet as part of its change tracking features (Printing Comments). Use this Excel oddity to impress your friends.
Sometimes Excel refuses to insert new worksheets exactly where you'd like them. Fortunately, you can easily rearrange any of your worksheets just by dragging their tabs from one place to another, as shown in Figure 4-8.
Figure 4-8. When you drag a worksheet tab, a tiny page appears beneath the arrow cursor. As you move the cursor around, you'll see a black triangle appear, indicating where the worksheet will land when you release the mouse button.
You can use a similar technique to create copies of a worksheet. Click the worksheet tab and begin dragging, just as you would to move the worksheet. However, before releasing the mouse button, press the Ctrl key (you'll see a plus sign [+] appear). When you let go, Excel creates a copy of the worksheet in the new location. The original worksheet remains in its original location. Excel gives the new worksheet a name with a number in parentheses. For example, a copy of Sheet1 is named Sheet1 (2). As with any other worksheet tab, you can change this name.
Once you get the hang of creating different worksheets for different types of information, your Excel files can quickly fill up with more sheets than a linens store. What happens when you want to shift some of these worksheets around? For instance, you may want to move (or copy) a worksheet from one Excel file to another. Here's how:
Open both spreadsheet files in Excel.
The file that contains the worksheet you want to move or copy is called the source file; the other file (where you want to move or copy the worksheet to) is known as the destination file.
Go to the source workbook.
Remember, you can move from one window to another using the Windows task bar, or by choosing the file's name from the ribbon's View→Windows→Switch Windows list.
Right-click the worksheet you want to transfer, and then, from the shortcut menu that appears, choose Move or Copy.
If you want, you can transfer multiple worksheets at once. Just hold down the Ctrl key, and then select all the worksheets you want to move or copy. Excel highlights all the worksheets you select (and groups them together). Right-click the selection, and then choose Move or Copy.
When you choose Move or Copy, the Move or Copy dialog box appears (as shown in Figure 4-9).
Choose the destination file from the "To book" list.
The "To book" drop-down list shows all the currently open workbooks (including the source workbook).
Figure 4-9. Here, the selected worksheet is about to be moved into the SimpleExpenses.xlsx workbook. (The source workbook isn't shown.) The SimpleExpenses workbook already contains three worksheets (named Sheet1, Sheet2, and Sheet3). Excel inserts the new worksheet just before the first sheet. Because the "Create a copy" checkbox isn't turned on, Excel removes the worksheet from the source workbook when it completes the transfer.
Excel also lets you move your worksheets to a new workbook, which it automatically creates for you. To move them to a new workbook, choose the "(new book)" item in the "To book" list. The new workbook won't have the standard three worksheets. Instead, it'll have only the worksheets you've transferred.
Specify the position where you want the worksheet inserted.
Choose a destination worksheet from the "Before sheet" list. Excel places the copied worksheets just before the worksheet you select. If you want to place the worksheets at the end of the destination workbook, select "(move to end)." Of course, you can always rearrange the worksheets after you transfer them, so you don't need to worry too much about getting the perfect placement.
If you want to copy the worksheet, turn on the "Create a copy" checkbox at the bottom of the window.
If you don't turn this option on, then Excel copies the worksheet to the destination workbook and removes it from the source workbook. If you do turn this option on, you'll end up with a copy of the worksheet in both workbooks.
As you've seen in previous chapters, Excel lets you work with more than one column, row, or cell at a time. The same holds true for worksheets. You can select multiple worksheets and perform an operation on all of them at once. This process of selecting multiple sheets is called grouping, and it's helpful if you need to hide or format several worksheets (for example, if you want to make sure all your worksheets start with a bright yellow first row), and you don't want the hassle of selecting them one at a time. Grouping sheets doesn't let you do anything you couldn't do ordinarily—it's just a nifty timesaver.
Here are some operations—all of which are explained in detail below—that you can simultaneously perform on worksheets that are grouped together:
Move, copy, delete, or hide the worksheets.
Apply formatting to individual cells, columns, rows, or even entire worksheets.
Enter new text, change text, or clear cells.
Cut, copy, and paste cells.
Adjust some page layout options, like paper orientation (on the Page Layout tab).
Adjust some view options, like gridlines and the zoom level (on the View tab).
To group worksheets, hold down Ctrl while clicking multiple worksheet tabs. When you're finished making your selections, release the Ctrl key. Figure 4-10 shows an example.
Figure 4-10. In this example, Sheet2 and Sheet3 are grouped. When worksheets are grouped, their tab colors change from gray to white. Also, in workbooks with groups, the title bar of the Excel window includes the word [Group] at the end of the file name.
To ungroup worksheets, right-click one of the worksheet tabs and select Ungroup Sheets, or just click one of the worksheet tabs that isn't in your group. You can also remove a single worksheet from a group by clicking it while holding down Ctrl. However, this technique works only if the worksheet you want to remove from the group is not the currently active worksheet.
As your workbook grows, you'll often need better ways to manage the collection of worksheets you've accumulated. For example, you might want to temporarily hide a number of worksheets, or move a less important batch of worksheets from the front (that is, the left side) of the worksheet tab holder to the end (the right side). And if a workbook's got way too many worksheets, you might even want to relocate several worksheets to a brand new workbook.
It's easy to perform an action on a group of worksheets. For example, when you have a group of worksheets selected, you can drag them en masse from one location to another in the worksheet tab holder. To delete or hide a group of sheets, just right-click one of the worksheet tabs in your group, and then choose Delete or Hide. Excel then deletes or hides all the selected worksheets (provided that action will leave at least one visible worksheet in your workbook).
Excel keeps track of print and display settings on a per-worksheet basis. In other words, when you set the zoom percentage to 50 percent in one worksheet so you can see more data, it doesn't affect the zoom in another worksheet. However, when you make the change for a group of worksheets, they're all affected in the same way.
When you format cells inside one grouped worksheet, it triggers the same changes in the cells in the other grouped worksheets. So you have another tool you can use to apply consistent formatting over a batch of worksheets. It's mainly useful when your worksheets are all structured in the same way.
For example, imagine you've created a workbook with 10 worksheets, each one representing a different customer order. If you group all 10 worksheets together, and then format just the first one, Excel formats all the worksheets in exactly the same way. Or say you group Sheet1 and Sheet2, and then change the font of column B in Sheet2—Excel automatically changes the font in column B in Sheet1, too. The same is true if you change the formatting of individual cells or the entire worksheet—Excel replicates these changes across the group. (To change the font in the currently selected cells, just select the column and, in the Home→Font section of the ribbon, make a new font choice from the font list. You'll learn much more about the different types of formatting you can apply to cells in Chapter 5.)
With grouped worksheets, you can also modify the contents of individual cells, including entering or changing text and clearing cell contents. For example, if you enter a new value in cell B4 in Sheet2, Excel enters the same value into cell B4 in the grouped Sheet1. Even more interesting, if you modify a value in a cell in Sheet2, the same value appears in the same cell in Sheet1, even if Sheet1 didn't previously have a value in that cell. Similar behavior happens when you delete cells.
Editing a group of worksheets at once isn't as useful as moving and formatting them, but it does have its moments. Once again, it makes most sense when all the worksheets have the same structure. For example, you could use this technique to put the same copyright message in cell A1 on every worksheet, or to add the same column titles to multiple tables (assuming they're arranged in exactly the same way). One example where grouped sheets make sense is if you have a different worksheet for every month of a year, but each one has the same overall structure.
Be careful to remember the magnified power your keystrokes possess when you're operating on grouped worksheets. For example, imagine that you move to cell A3 on Sheet1, which happens to be empty. If you click Delete, you see no change. However, if cell A3 contains data on other worksheets that are grouped, these cells are now empty. Grouper beware.
Cut and paste operations work the same way as entering or modifying grouped cells. Whatever action you perform on one grouped sheet, Excel also performs on other grouped sheets. For example, consider what happens if you've grouped together Sheet1 and Sheet2, and you copy cell A1 to A2 in Sheet1. The same action takes place in Sheet2—in other words, Excel copies the contents of cell A1 (in Sheet2) to cell A2 (also in Sheet2). Obviously, the contents of cell A1 and A2 in Sheet1 may be different from the contents of cell A1 and A2 in Sheet2—the grouping simply means that whatever was in cell A1 will now also be in cell A2.