Get Current Month Name From Today’s Date using Excel VBA Functions. Name of the current month plays an important major role of a date. We can get current month name using month function and can summarize data with it. Once we get month name we can Format name of the month by using format function as per our requirement.
VBA Find Name of the Current Month:
Let us see the procedure how to get name of the month from today’s date using MonthName function.
'Procedure to find Name of the Current Month From Date Sub VBA_Get_Current_Month_Name() 'Variable declaration Dim sMonth_Name As String 'Retrieve month Name from date sMonth_Name = MonthName(Month(Date)) 'Display month name MsgBox "Today's Date is " & Date & ", And " & vbCrLf & _ "Current Month name is : " & sMonth_Name, vbInformation, "Month Name From Date" End Sub
Explanation: In the above procedure we have used Month, Date and MonthName VBA functions. Here Month function is used to display month number. MonthName function helps to generate name of the month from specified month number. Here is the output screenshot for your reference.
Format Name of the Month:
We have different format methods to format name of the month. You can find output in an immediate window.
'Format Name of the Month Sub VBA_Format_Month_Name() 'Variable declaration Dim sMonth_Name As String sMonth_Name = Format("01/01/2018", "m") Debug.Print sMonth_Name sMonth_Name = Format("01/01/2018", "mm") Debug.Print sMonth_Name sMonth_Name = Format("01/01/2018", "mmm") Debug.Print sMonth_Name sMonth_Name = Format("01/01/2018", "mmmm") Debug.Print sMonth_Name End Sub
Output screenshot: Here is the output screenshot of the above macro procedure. we have shown four different format methods.
Instructions to Run VBA Macro Code or Procedure:
You can refer the following link for the step by step instructions.
Instructions to run VBA Macro Code
Other Useful Resources:
Click on the following links of the useful resources. These helps to learn and gain more knowledge.
VBA Tutorial VBA Functions List VBA Arrays VBA Text Files VBA Tables
VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers Blog
2 thoughts on “VBA Current Month Name”
I have read so many posts on the topic of the blogger
lovers however this paragraph is really a good paragraph, keep it up.
Hi there very nice web site!! Guy .. Excellent ..
Wonderful .. I will bookmark your web site and take the feeds also?
I’m glad to search out a lot of useful information here
in the publish, we want develop more techniques in this regard, thanks for sharing.
. . . . .