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

Working with Formulas and Functions<br />

ON the CD-ROM<br />

This workbook is available on the companion CD-ROM. The file is named array formula<br />

calendar.xlsx.<br />

To create this calendar in the range B2:H9, follow these steps:<br />

1. Select B2:H2 and merge the cells by choosing Home ➪ Alignment ➪ Merge & Center.<br />

2. Enter a date into the merged range. The day of the month isn’t important.<br />

3. Enter the abbreviated day names in the range B3:H3.<br />

4. Select B4:H9 and enter this array formula. Remember, to enter an array formula, use<br />

Ctrl+Shift+Enter (not just Enter).<br />

{=IF(MONTH(DATE(YEAR(B2),MONTH(B2),1))MONTH(DATE(YEAR(B2),<br />

MONTH(B2),1)-(WEEKDAY(DATE(YEAR(B2),MONTH(B2),1))-1)+<br />

{0;1;2;3;4;5}*7+{1,2,3,4,5,6,7}-1),””,<br />

DATE(YEAR(B2),MONTH(B2),1)-(WEEKDAY(DATE(YEAR(B2),MONTH(B2),1))-1)+<br />

{0;1;2;3;4;5}*7+{1,2,3,4,5,6,7}-1)}<br />

5. Format the range B4:H9 to use this custom number format: d. This step formats the dates to<br />

show only the day. Use the Custom category in the Number tab of the Format Cells dialog box to<br />

specify this custom number format.<br />

6. Adjust the column widths and format the cells as you like.<br />

Change the month and year in cell B2, and the calendar will update automatically. After creating this calendar,<br />

you can copy the range to any other worksheet or workbook.<br />

FIGURE 18.11<br />

Displaying a calendar by using a single array formula.<br />

The array formula actually returns date values, but the cells are formatted to display only the day portion of<br />

the date. Also, notice that the array formula uses array constants.<br />

CROSS-REF<br />

See Chapter 17 for more information about array constants.<br />

348

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

Saved successfully!

Ooh no, something went wrong!