View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dianne Dianne is offline
external usenet poster
 
Posts: 107
Default TEXT(Cell1,"MMMM YYYY") to work in all locale.

You could use VBA to create the correct function:

This has not been tested with other regional formats, but works with my
Canadian settings. It's kind of awkward, but I don't know of any other
way to do this.

Sub SetFormula()

Dim strM As String
Dim strY As String
Dim strFormat As String
Dim strDQ As String

strDQ = Chr(34)

strM = Application.International(xlMonthCode)
strY = Application.International(xlYearCode)

strFormat = strM & strM & strM & strM & " " & strY & strY & strY &
strY

ActiveSheet.Range("B2").Formula = _
"=" & strDQ & "Month :- " & strDQ & _
" & TEXT($A$2, " & strDQ & strFormat & strDQ & ")"

End Sub

--
HTH,
Dianne

In ,
Kevin McCartney typed:
Hi TWIMC
The following funtion works on a computer that has "English" date
format setting each YYYY to represent a four digit year, but if view
the same workbook on a computer that has "German" settings I don't
see a four digit year I only see YYYY. The letter that represents Y
for Year in German is J for Jahr, so I know it relates to the locale.
My question is that if Excel is locale supportive in that the IF
function is translated WENN or VLOOKUP is translated to SVERWIES then
how come it does not translate text formats like MMMM YYYY and
translate them automatically to MMMM JJJJ. In any case how do I
overcome this problem.

(English settings)
="Month :- " & TEXT($A$2,"MMMM YYYY") where A2 = 01/01/2004 I would
see Month :- " January 2004"

(German settings)
="Month :- " & TEXT($A$2,"MMMM YYYY") where A2 = 01.01.2004 I would
see Month :- " Januar YYYY"

TIA
KM