Microsoft Office Tutorials and References

In Depth Information

Figure 26-7:
The MONTHNAMES function entered as an array formula.

As with any array formula, you must press Ctrl+Shift+Enter to enter the formula. Don't

enter the brackets — Excel inserts the brackets for you.

The MONTHNAMES function, as written, returns a horizontal array in a single row. To display the array in a

vertical range in a single column (as in A7:A18 in Figure 26-5), select the range and enter the following for-

mula:

{=TRANSPOSE(MONTHNAMES())}

Alternatively, you can modify the function to do the transposition. The following function uses the Excel

TRANSPOSE function to return a vertical array:

Function VMONTHNAMES() As Variant

VMONTHNAMES = Application.Transpose(Array( _

“Jan”, “Feb”, “Mar”, “Apr”, _

“May”, “Jun”, “Jul”, “Aug”, _

“Sep”, “Oct”, “Nov”, “Dec”))

End Function

The workbook monthnames.xlsm that demonstrates MONTHNAMES and

VMONTHNAMES is available at this topic's website.

Returning an array of nonduplicated random integers