Why VBA Format(1, 'mmm') Returns December and How to Fix It
Question details
The user is trying to convert a numeric month value into an abbreviated month string, but the Format function returns an unexpected month.

- Product
- Excel VBA
- Device & OS
- not provided
- Scenario
- Converting an integer representing a month (such as 1 for January) into its corresponding abbreviated name (Jan) or full name (January) using a VBA macro.
- Observed behavior
- Using Format(1, "mmm") returns 'December' or 'Dec' instead of the expected 'January' or 'Jan'.
Verify whether your input variable is a simple integer (1-12) or an actual Date serial number, as VBA handles these two data types differently when applying formats.
Use the VBA MonthName Function (Recommended)
The most direct and reliable way to get a month name from an integer (1 to 12) is using the built-in MonthName function.
When you pass a simple integer like 1 to the Format function with 'mmm' or 'mmmm', VBA assumes it is a date serial number. In the VBA date system, the serial number 1 corresponds to December 31, 1899. This is why formatting the number 1 directly returns 'December'.
To fix this, you should use the MonthName function, which is specifically designed to translate month integers into their corresponding text names.
Press Alt + F11 in your spreadsheet application to open the VBA Editor, and locate the module containing your code.
Find the line of code using the Format function, such as: result = Format(PreviousMonth, "mmm")
Change the code to use MonthName instead. To get the abbreviated name ('Jan' for 1), use: result = MonthName(1, True)
If you need the full month name ('January' for 1), simply omit the second argument or set it to False: result = MonthName(1)

Construct a Valid Date for the Format Function
If you must use the Format function for a specific reason, you can construct a complete date first using the DateSerial function so VBA formats the correct month.
Write and Run VBA Macros Seamlessly in WPS Office
WPS Office provides robust support for writing and running VBA macros. You can edit your code, use functions like MonthName, and automate tasks in WPS Spreadsheet exactly as you would in other major office suites.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook in the Spreadsheet application.
- 2. Access the Macro Editor: Go to the Tools tab on the ribbon and click on 'Macro', or simply press Alt + F11 to open the built-in VBA Editor.
- 3. Update your VBA Code: Replace any instance of Format(1, "mmm") with MonthName(1, True) to ensure correct date formatting.
- 4. Run your Macro: Press F5 or click the Run button to execute your code and verify the correct month names are generated.

Frequently Asked Questions
Why does the number 1 translate to December in VBA?
VBA stores dates as sequential serial numbers starting from late 1899. The serial number 1 represents December 31, 1899. Therefore, when you format the number 1 to extract the month, VBA looks at that 1899 date and returns December.
How do I get the current month's name in VBA?
You can use MonthName(Month(Date)) to extract the current month number from today's system date and convert it directly into the full month name.
Does the MonthName function work for month numbers above 12?
No, the MonthName function strictly accepts integers from 1 to 12. Passing a number outside this range (like 0 or 13) will result in an 'Invalid procedure call or argument' runtime error.




