Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Macro for Month Name.
Written by Allen Wyatt (last updated September 19, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003
Brian is looking for a macro that returns the full name of the current month, such as July, August, etc. Before getting to the macros, it should be mentioned that depending on your needs, you can get the desired information with one of several formulas. Perhaps the easiest formula is the following:
=Today()
Place the formula into a cell, and you end up with today's date. Format the cell using a custom format, and you end up with the full month name. The custom format is applied by using these steps:
Figure 1. The Number tab of the Format Cells dialog box.
Another formulaic approach is to use the following in a cell:
=Text(Today(),"mmmm")
No special formatting is required; the formula returns the text of the full month name for whatever today is. Finally, you could use an even longer formula that simply picks the month name from a list of months:
=CHOOSE(MONTH(NOW()),"January","February", "March","April","May","June","July", "August","September","October","November", "December")
Remember that this is a single formula; it goes all in one cell.
Which brings us, finally, to the macros. If you want a macro that returns the month name in the current cell, you are looking for a user-defined function:
Function MonthName() Application.Volatile MonthName = Format(Date, "mmmm") End Function
This simple two-line macro dynamically returns the month name for whatever the current date is. Just put this formula in a cell:
=MonthName()
Remember—since you've just added a macro to your workbook, you'll be asked whenever you open your workbook if you want to enable macros. If you don't want to see this question all the time, you should use one of the formulaic approaches presented earlier.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2915) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Macro for Month Name.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
If you need to insert the current time, with seconds, then you'll need the macro discussed in this tip. It's easy to use ...
Discover MoreWant to know how much of a time difference there is between your machine and a different machine? This tip provides some ...
Discover MoreExcel has a number of functions that are available as an add-on in the Analysis ToolPak. One of these functions allows ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-09-19 11:43:16
Rick Rothstein
For those who might find this interesting, there is a simple way to get the Month name from the month number in both VBA and via Excel formula.
In VBA this is dirt simple as there is a function for it... MonthName (figures, right?). Simply pass the number in and the function returns the full name. There is an optional Boolean argument that when set to True returns the abbreviated month name instead.
Now for the Excel formula (cell A1 is assumed to contain a number between 1 and 12)...
=TEXT(28*A1,"mmmm")
You can also use 29 in place of the 28 and it will still work. Both of those numbers will work correctly in the 1904 date system as well. If you never work in the 1904 date system, you can also use 30 in place of the 28 and that will also work.
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments