11.08.2013 Views

Excel's Formula - sisman

Excel's Formula - sisman

Excel's Formula - sisman

SHOW MORE
SHOW LESS

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

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

550<br />

Part V: Miscellaneous <strong>Formula</strong> Techniques<br />

If the formula that you enter contains a cell reference, that reference will be considered to be a<br />

relative reference, based on the active cell in the selected range. This works exactly the same as<br />

using a formula for conditional formatting. (See the “Creating formula-based rules” section, earlier<br />

in this chapter.)<br />

Using data validation formulas to accept only specific entries<br />

Each of the following data validation examples uses a formula entered directly into the <strong>Formula</strong><br />

control in the Data Validation dialog box. You can set up these formulas to accept only text, a<br />

certain value, nonduplicate entries, or text that begins with a specific letter.<br />

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

is 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<br />

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

only text (no 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 allows the user to enter a value only if it’s greater than the<br />

value in the cell directly above it:<br />

=A2>A1<br />

Using custom worksheet functions in data<br />

validation formulas<br />

Earlier in this chapter, I describe how to use custom VBA functions for conditional formatting<br />

(see the “Using custom functions in conditional formatting formulas” section). For some reason,<br />

Excel does not permit you to use a custom VBA function in a data validation formula. If you<br />

attempt to do so, you get the following (erroneous) error message: A named range you<br />

specified cannot be found.<br />

To bypass this limitation, you can use the custom function in a cell formula and then specify a<br />

data validation formula that refers to that cell.

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

Saved successfully!

Ooh no, something went wrong!