Adding a Custom Function That Returns the Quarter Number

To add a custom function to a Module in the Personal Macro Workbook (To learn more about creating a Personal Macro Workbook.

1. Press Alt+F11 to open the VBE.
2. Double-click a Module name in the Personal Macro Workbook, or insert a new Module into the Personal Macro Workbook by selecting Module from the Insert menu.
3. Enter the following code lines into the Module:

Function QuarterNum(Enter_Date)
QuarterNum = DatePart ("q", Enter_Date)
End Function

To test the Custom Function:

1. Select any empty cell and press Shift+F3 to open the Paste Function dialog box.
2. In the User Defined category, select QuarterNum, and then click OK.
3. In the Function Arguments dialog box, enter the address of a cell containing a date, and click OK.