18.11.2014 Views

Microsoft Office

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Part IV<br />

Using Advanced Excel Features<br />

Follow these steps:<br />

1. Select the range B2:B10 and ensure that cell B2 is the active cell.<br />

2. Choose Data ➪ Data Tools ➪ Data Validation. The Data Validation dialog box appears.<br />

3. Click the Settings tab and select Custom from the Allow drop-down list.<br />

4. Enter the following formula in the Formula box, as shown in Figure 25.5:<br />

=ISODD(B2)<br />

This formula uses Excel’s ISODD function, which returns True if its numeric argument is an odd<br />

number. Notice that the formula refers to the active cell, which is cell B2.<br />

5. Click the Error Alert tab and choose Stop for the Style and type An odd number is required<br />

here as the Error Message.<br />

6. Click OK to close the Data Validation dialog box.<br />

Notice that the formula entered contains a reference to the upper-left cell in the selected range. This Data<br />

Validation formula was applied to a range of cells, so you might expect that each cell would contain the<br />

same Data Validation formula. Because you entered a relative cell reference as the argument for the ISODD<br />

function, Excel adjusts the Data Validation formula for the other cells in the B2:B10 range. To demonstrate<br />

that the reference is relative, select cell B5 and examine its Data Validation formula. You’ll see that the formula<br />

for this cell is<br />

=ISODD(B5)<br />

FIGURE 25.5<br />

Entering a Data Validation formula.<br />

Generally, when entering a Data Validation formula for a range of cells, you use a reference to the active cell,<br />

which is normally the upper-left cell in the selected range. An exception is when you need to refer to a specific<br />

cell. For example, suppose that you select range A1:B10, and you want your Data Validation to allow<br />

only values that are greater than C1. You would use this Data Validation formula:<br />

=A1>$C$1<br />

486

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!