
- VBA Tutorial
- VBA - Home
- VBA - Overview
- VBA - Excel Macros
- VBA - Excel Terms
- VBA - Macro Comments
- VBA - Message Box
- VBA - Input Box
- VBA - Variables
- VBA - Constants
- VBA - Operators
- VBA - Decisions
- VBA - Loops
- VBA - Strings
- VBA - Date and Time
- VBA - Arrays
- VBA - Functions
- VBA - Sub Procedure
- VBA - Events
- VBA - Error Handling
- VBA - Excel Objects
- VBA - Text Files
- VBA - Programming Charts
- VBA - Userforms
- VBA Useful Resources
- VBA - Quick Guide
- VBA - Useful Resources
- VBA - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
VBA - Month Name
The MonthName function returns the name of the month for the specified date.
Syntax
MonthName(month[,toabbreviate])
Parameter Description
Month − A required parameter. It specifies the number of the month.
Toabbreviate − An optional parameter. A Boolean value that indicates if the month name is to be abbreviated. If left blank, the default value would be taken as False.
Example
Add a button and add the following function.
Private Sub Constant_demo_Click() msgbox("Line 1 : " & MonthName(01,True)) msgbox("Line 2 : " & MonthName(01,false)) msgbox("Line 3 : " & MonthName(07,True)) msgbox("Line 4 : " & MonthName(07,false)) End Sub
When you execute the above function, it produces the following output.
Line 1 : Jan Line 2 : January Line 3 : Jul Line 4 : July
vba_date_time.htm
Advertisements