ด้านบนเป็นเพียงการเติมอักษรต่อท้ายเลขวันที่ครับ
ส่วนมาโครด้านล่างนี่ผมก็แก้จากชื่อเดือนภาษาไทยเป็นชื่อเดือนภาษาอังกฤษครับ
ตัวอย่างการนำไปใช้งาน =Format(Date(),"d ") & MonthNameEng(Date()) & " " & Year(Date()) = 25 February 2020
Option Compare Database
Public Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Public Declare Function GetLocaleInfo Lib "kernel32" _
Alias "GetLocaleInfoA" _
(ByVal Locale As Long, _
ByVal LCType As Long, _
ByVal lpLCData As String, _
ByVal cchData As Long) As Long
Public Function GetUserLocaleInfo(ByVal dwLocaleID As Long, ByVal dwLCType As Long) As String
Dim sReturn As String
Dim r As Long
r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
If r Then
sReturn = Space$(r)
r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
If r Then GetUserLocaleInfo = Left$(sReturn, r - 1)
End If
End Function
Public Function mYear(ByVal yourDate As Date) As Long
mYear = Year(yourDate)
If GetUserLocaleInfo(GetSystemDefaultLCID(), &H1009) = 7 Then mYear = Year(yourDate)
End Function
Public Function bYear(ByVal yourDate As Date) As Long
bYear = Year(yourDate)
'If GetUserLocaleInfo(GetSystemDefaultLCID(), &H1009) <> 7 Then bYear = Year(yourDate) + 543
If GetUserLocaleInfo(GetSystemDefaultLCID(), &H1009) = 7 Then bYear = ((Year(yourDate) + 543) - 2500)
End Function
Function MonthNameEng(ByVal yourDate) As String
If Not IsNull(yourDate) Then
yourDate = Format(yourDate, "m")
Select Case yourDate
Case 1
MonthNameEng = "January"
Case 2
MonthNameEng = "February"
Case 3
MonthNameEng = "March"
Case 4
MonthNameEng = "April"
Case 5
MonthNameEng = "May"
Case 6
MonthNameEng = "June"
Case 7
MonthNameEng = "July"
Case 8
MonthNameEng = "August"
Case 9
MonthNameEng = "September"
Case 10
MonthNameEng = "October"
Case 11
MonthNameEng = "November"
Case 12
MonthNameEng = "December"
Case Else
MonthNameEng = ""
End Select
End If
End Function
มาแถมถ้าอยากให้มีอักษรต่อท้ายด้วยอีก
1. แก้มาโครแรกให้ FancyDate = FancyDate & Format(dteInput, " ")
2. =FancyDate(Date()) & MonthNameEng(Date()) & " " & Year(Date()) จะได้ 25th February 2020