18.11.2014 Views

Microsoft Office

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using Data Validation 25<br />

In this case, the reference to cell C1 is an absolute reference; it will not be adjusted for the cells in the<br />

selected range — which is just what you want. The Data Validation formula for cell A2 looks like this:<br />

=A2>$C$1<br />

The relative cell reference is adjusted, but the absolute cell reference is not.<br />

Data Validation Examples<br />

The following sections contain a few data validation examples that use a formula entered directly into the<br />

Formula control on the Settings tab of the Data Validation dialog box. These examples help you understand<br />

how to create your own Data Validation formulas.<br />

ON the CD-ROM<br />

All the examples in this section are available on the companion CD-ROM. The file is named<br />

data validation examples.xlsx.<br />

Accepting text only<br />

Excel has a Data Validation option to limit the length of text entered into a cell, but it doesn’t have an<br />

option to force text (rather than a number) into a cell. To force a cell or range to accept only text (no<br />

values), use the following data validation formula:<br />

=ISTEXT(A1)<br />

This formula assumes that the active cell in the selected range is cell A1.<br />

Accepting a larger value than the previous cell<br />

The following data validation formula enables the user to enter a value only if it’s greater than the value in<br />

the cell directly above it:<br />

=A2>A1<br />

This formula assumes that A2 is the active cell in the selected range. Note that you can’t use this formula for<br />

a cell in row 1.<br />

Accepting nonduplicate entries only<br />

The following data validation formula does not permit the user to make a duplicate entry in the range<br />

A1:C20:<br />

=COUNTIF($A$1:$C$20,A1)=1<br />

This formula assumes that A1 is the active cell in the selected range. Note that the first argument for<br />

COUNTIF is an absolute reference. The second argument is a relative reference, and it adjusts for each<br />

cell in the validation range. Figure 25.6 shows this validation criterion in effect, using a custom error alert<br />

message. The user is attempting to enter 17 into cell B6.<br />

487

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

Saved successfully!

Ooh no, something went wrong!