Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Determining the Month of the Year.
Written by Allen Wyatt (last updated April 22, 2023)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021
When creating macros in VBA, you may have a need to know the specific month of the year, as represented by a particular date. For instance, you may want to determine the month in which the macro is being executed. The following code will do the trick:
iMonth = Month(Now())
The Month function returns an integer value representing the numeric month of whatever date you provide. In this example, the Now function represents today's date, and so Month returns the current month, as a value ranging from 1 to 12.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12343) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Word here: Determining the Month of the Year.
Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!
Want the ribbon to be minimized for a particular document? Word may not allow you to get the exact result you want, as ...
Discover MoreWhen using a macro to process a document in some way, you often need to know the number of paragraphs in the document. ...
Discover MoreOne of the most common ways of creating macros is to use Word's macro recorder. This tip shows how easy it is to use the ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments