将月份名称转换为3个字母的缩写

任何人都知道如何将一个月份名称转换成3个字母的缩写? 例如,如果月份是九月,那么它应该只返回九月份。 我一直在网上search,但不幸的是得到了答案。 谢谢!

试试下面

Sub test() Dim a As String a = Format("11/10/2015", "MMM") MsgBox a End Sub 

要么

 Sub test() Dim a As String a = Format(Now(), "MMM") MsgBox a End Sub 

如果你有月份名称作为variables那么

 Sub test() Dim a As String a = "February" MsgBox Mid(a, 1, 3) End Sub 

总是能够发挥自己的作用,例如:

 Function Month2Mon(month) As String Select Case LCase(month) Case "january": Month2Mon = "Jan" Case "february": Month2Mon = "Feb" ... End Function 

你也可以试试这个:

 Sub Demo() Dim MonthName As String MonthName = "September" MsgBox Format(DateValue("01 " & MonthName & " 2012"), "MMM") End Sub 

这个解决scheme是从@ SiddhartRout的答案派生出来的。