Microsoft Office Tutorials and References

In Depth Information

**Function Examples**

This procedure uses the
Mod
operator to determine the month value. The
Mod
operator

returns the remainder after dividing the first operand by the second. Keep in mind that

the
AllNames
array is zero-based and that indices range from 0 to 11. In the statement

that uses the
Mod
operator, 1 is subtracted from the functionâ€™s argument. Therefore, an

argument of
13
returns
0
(corresponding to Jan), and an argument of
24
returns
11

(corresponding to Dec).

You can use this function in a number of ways, as illustrated in Figure 10-6.

Range A1:L1 contains the following formula entered as an array. Start by selecting A1:L1, enter the

formula (without the braces), and then press Ctrl+Shift+Enter.

{=MonthNames()}

Range A3:A14 contains integers from 1 to 12. Cell B3 contains the following (nonarray) formula,

which was copied to the 11 cells below it:

=MonthNames(A3)

Range D3:D14 contains the following formula entered as an array:

{=MonthNames(-1)}

Figure 10-6:
Different ways of passing an array or a single value to a worksheet.

Range F3 contains this (nonarray) formula:

=MonthNames(3)