VBA - Change date language

前端 未结 3 1309
遇见更好的自我
遇见更好的自我 2020-12-21 01:48

I\'m trying to solve such problem: In macro, that I\'m using, one of the parts is to retrieve date month (in full naming), currently is used :

LastMonth =          


        
相关标签:
3条回答
  • 2020-12-21 02:11

    Try this, found it on a forum and it seems to work.

    Public Function Format_en(Datum As Date) As String 
    Dim DD              As String 
    Dim MMM             As String 
    Dim YY              As String 
    
    DD = Format(Datum, "dd") 
    MMM = Choose(Month(Datum), "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") 
    YY = Format(Datum, "yy") 
    
    Format_en = DD & "." & MMM & " " & YY 
    End Function 
    
    MsgBox Format_en(Date) 
    

    Reference: http://www.office-loesung.de/ftopic99887_0_0_asc.php

    Cheers

    0 讨论(0)
  • 2020-12-21 02:11

    Just use [$-409] to force English number format.

    .NumberFormat = "[$-409]mmmm yy"

    gives an output like e.g. "December 19".

    .NumberFormat = "[$-409]mmm yy"

    gives an output like e.g. "Dec 19".

    0 讨论(0)
  • 2020-12-21 02:35

    Excel formula TEXT allows defining output language, so one of the options is to use it's VBA equivalent:

    LastMonth = WorksheetFunction.Text(Date - Day(Date), "[$-409]mmmm")
    
    0 讨论(0)
提交回复
热议问题