By David Hawley, Raina Hawley
Book Price: $29.99 USD
£20.99 GBP
PDF Price: $23.99
Cover | Table of Contents | Colophon
Excel enables you to have multiple workbooks showing simultaneously, and to have a customized view of your workbooks arranged in different windows. Then you can save your view workspaces as .xlw files and use them when it suits you.
It's fairly ordinary to need some data to be duplicated in multiple worksheets. You can use Excel's tool for grouping so that data entered in one workbook can be entered into multiple worksheets simultaneously. But there is also a quicker and more flexible approach that uses a couple of lines of Visual Basic for Applications (VBA) code.Sheet object. To quickly go to the private module, right-click the Sheet Name tab and select View Code. You can then use one of Excel's sheet events—which are events that take place within your worksheet, such as changing a cell, selecting a range, activating, deactivating, and so on—to move the code into the private module for the
Although Excel provides overall protection for workbooks and worksheets, this blunt instrument doesn't provide limited privileges to users—unless you do some hacking.
Excel's chattiness can get a little old, always prompting you to confirm actions you just asked it to perform. Quit the conversation and let Excel get back to the action.
Sometimes you want a place for information that users can't read or modify. Build a backstage into your workbook, a place to keep data, formulas, and other minutiae consumed by, but not seen in, your sheets.Visible property, making it xlVeryHidden. Go to Developer → Visual Basic or Alt/Option-F11 to get to the VBE (pre-2007, go to Tools → Macro → Visual Basic Editor and make sure the Project Explorer window is visible by selecting View → Project Explorer). Find the name of your workbook within the Project Explorer and expand its hierarchy by clicking the + to the left of the workbook's name. Expand the Microsoft Excel Objects folder within to reveal all your workbook's worksheets.Visible property at the very bottom. Click the value box on the right associated with the Visible property and select the last option, 2-xlSheetVeryHidden, as shown in . Press Alt/⌘-Q to return to Excel, then save your changes. The sheet will no longer be visible via the Excel interface and won't appear as a choice under View → Unhide under Window options (pre-2007, Format → Sheet → Unhide…).2 -xlSheetVeryHidden
If you tend to perform the same tasks or use the same spreadsheet layouts again and again, you can build your own Template tab into Excel's standard Insert Template dialog to provide a quick starting point.
If you've spent much time in a workbook with many worksheets, you know how painful it can be to find a particular worksheet. An index sheet available to every worksheet is a navigational must-have.Sheet object. Insert a new worksheet into your workbook and name it something appropriate—Index, for instance. Right-click the index sheet's tab and select View Code from the context menu or select Alt/Option-F11.
Private Sub Worksheet_Activate( )
Dim wSheet As Worksheet
Dim l As Long
l = 1
With Me
.Columns(1).ClearContents
.Cells(1, 1) = "INDEX"
.Cells(1, 1).Name = "Index"
End With
For Each wSheet In Worksheets
If wSheet.Name <> Me.Name Then
l = l + 1
With wSheet
.Range("A1").Name = "Start" & wSheet.Index
.Hyperlinks.Add Anchor:=.Range("A1"), Address:="", SubAddress:= _
"Index", TextToDisplay:="Back to Index"
End With
Me.Hyperlinks.Add Anchor:=Me.Cells(l, 1), Address:="", _
SubAddress:="Start" & wSheet.Index, TextToDisplay:=wSheet.Name
End If
Next wSheet
End Sub
If you move around your spreadsheet a lot, or if you have data you don't want readers to explore, you might find it convenient to limit the visible area of your spreadsheet to only that which has actual data.
You may want to let users change cells that contain data without providing them access to change formulas. You can keep cells containing formulas under lock and key without having to protect your entire sheet or workbook.
Excel's conditional formatting is generally used to identify values in particular ranges, but we can hack it to identify duplicated data within a list or table. The improved functionality in Conditional Formatting in Excel 2007 makes this hack suitable for prior versions only.=COUNTIF($A$1:$H$100,A1)>1
COUNTIF criterion. By this we mean that the conditional formatting formula in cell A1 will read as follows:=COUNTIF($A$1:$H$100,A1)>1
=COUNTIF($A$1:$H$100,A2)>1
=COUNTIF($A$1:$H$100,A3)>1
While Excel's Conditional Formatting is vastly improved in Excel 2007 and can easily take care of duplicated data, it still does not offer the facility to identify data that appears two or more times.=COUNTIF($A$1:$H$100,A1)>3
=COUNTIF($A$1:$H$100,A1)=3
=COUNTIF($A$1:$H$100,A1)=2
Although most toolbars you build apply to just about any work you do, sometimes the functionality of a custom toolbar applies to only one workbook in particular. With this hack, you can tie custom toolbars to their respective workbooks. The Quick Access Toolbar options in Excel 2007 make this hack suitable for prior versions only.Private Sub Workbook_Activate( ) On Error Resume Next With Application.CommandBars("MyCustomToolbar") .Enabled = True .Visible = True End With On Error GoTo 0 End Sub Private Sub Workbook_Deactivate( ) On Error Resume Next Application.CommandBars("MyCustomToolbar").Enabled = False On Error GoTo 0 End Sub
In Excel, a formula reference can be either relative or absolute, but sometimes you want to move cells that use relative references without making the references absolute. Here's how.$A$1. Once you do this, no matter where you copy your formula, the formula will reference the same cells. Sometimes, however, you may have already set up a lot of formulas that contain not absolute references, but relative references. You would usually do this so that when you copy the original cell formula down or across, the row and column references change accordingly.
Ah, phantom links. You open your workbook and are prompted to "Update Links," but there are no links! How can you update links when they don't exist?
Ever notice that your workbook is increasing in size at an alarming rate for no apparent reason? There are several causes of workbook bloat, and some slimming solutions. The introduction of workbook size being limited only by the amount of memory your system in Excel 2007 will allow should eliminate workbook bloat; however, you may find some of the following tips handy if you have a particularly large workbook.
Workbook corruption can mean the loss of vital data, costing you more than just money. This hack explores some methods that might recover your data.
Data validation makes it easy to specify rules your data must follow. Unfortunately, Excel insists that lists used in data validation must appear on the same worksheet as the data being validated. Fortunately, there are ways to evade this requirement.INDIRECT function enables you to reference a cell containing text that represents a cell address. You then can use that cell as a local cell reference, even though it gets its data from another worksheet. You can use this feature to reference the worksheet where your list resides.$A$1:$A$8. Click any cell on a different worksheet where you want to have this validation list (pick list) appear. Then, under the Data tab, select Data → Data Validation (pre-2007, Data → Validation). Choose List from the Allow: field. In the Source: box, enter the following code:
Data validation makes it easy to specify rules your data must follow. Unfortunately, Excel insists that lists used in data validation must appear on the same worksheet as the data being validated. Fortunately, there are ways to evade this requirement.INDIRECT function enables you to reference a cell containing text that represents a cell address. You then can use that cell as a local cell reference, even though it gets its data from another worksheet. You can use this feature to reference the worksheet where your list resides.$A$1:$A$8. Click any cell on a different worksheet where you want to have this validation list (pick list) appear. Then, under the Data tab, select Data → Data Validation (pre-2007, Data → Validation). Choose List from the Allow: field. In the Source: box, enter the following code:
=INDIRECT("Sheet1!$A$1:$A$8")
INDIRECT
Although conditional formatting is one of Excel's most powerful features, it's a nuisance to turn it on and off through the ribbon. Adding checkboxes to your worksheet that turn formatting on and off makes it much easier to read data in any way you want, whenever you want.TRUE or FALSE value (checked/not checked) to their linked cell. By combining a checkbox from the Form Controls with conditional formatting using the "Use a formula to determine which cells to format" option (Formula Is in pre-2007 versions), as shown in , you can turn conditional formatting on and off via a checkbox.TRUE. For this reason, any formula you use in this hack must return either TRUE or FALSE.
Once a formula is entered into a cell, you can tell whether the cell is a static value or a value derived from a formula only by clicking in each cell and looking in the Formula bar, or by pressing Ctrl-~ (tilde). This hack fills that gap with a custom function.=CELL("Type",A1) in the "Use a formula to determine which cells to format" section, but you must be aware that this is a volatile function. This means that every time you make any changes at all in the workbook, or another workbook while the workbook containing the conditional formatting is still open, it will force all the cells using the CELL function to recalculate. These global recalculations can add considerably to your overhead in a large spreadsheet. This hack presents a better way.Function IsFormula(Check_Cell As Range) IsFormula = Check_Cell.HasFormula End Function
=IsFormula($A$1). You also can access the function by going to the Formulas tab, selecting Function Library → Insert Function (pre-2007, Insert → Function), selecting User Defined from the Category option, and choosing IsFormula from the functions displayed.TRUE if the reference cell houses a formula and FALSE if it does not. You can use this Boolean result in conjunction with conditional formatting so that all formulas are highlighted automatically in a format of your choice.
Once you can see the results of conditional formatting, you might want to create formulas that reference only the data that was conditionally formatted. Excel doesn't quite understand this in its calculations, but it can learn.SUMIF function to add a range of cells that meet a certain criterion—but only one criterion. If you need to deal with more than one factor, you can use an ar