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.

Part III<br />

Creating Charts and Graphics<br />

FIGURE 21.16<br />

Creating a conditional formatting rule based on a formula.<br />

Conditional formatting formula examples<br />

Each of these examples uses a formula entered directly into the New Formatting Rule dialog box, after<br />

selecting the rule type labeled Use A Formula To Determine Which Cells To Format. You decide the type of<br />

formatting that you apply conditionally.<br />

ON the CD-ROM<br />

The companion CD-ROM contains all the examples in this section. The file is named conditional<br />

formatting formulas.xlsx.<br />

Identifying weekend days<br />

Excel provides a number of conditional formatting rules that deal with dates, but it doesn’t let you identify<br />

dates that fall on a weekend. Use this formula to identify weekend dates:<br />

=OR(WEEKDAY(A1)=7,WEEKDAY(A1)=1)<br />

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

Displaying alternate-row shading<br />

The conditional formatting formula that follows was applied to the range A1:D18, as shown in Figure 21.17,<br />

to apply shading to alternate rows.<br />

=MOD(ROW(),2)=0<br />

Alternate row shading can make your spreadsheets easier to read. If you add or delete rows within the conditional<br />

formatting area, the shading is updated automatically.<br />

This formula uses the ROW function (which returns the row number) and the MOD function (which returns<br />

the remainder of its first argument divided by its second argument). For cells in even-numbered rows, the<br />

MOD function returns 0, and cells in that row are formatted.<br />

For alternate shading of columns, use the COLUMN function instead of the ROW function.<br />

436

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

Saved successfully!

Ooh no, something went wrong!