name of month in national language

S

Stefi

Hi All,

I wanted to get the Hungarian name of months in VBA in my Hungarian version
with the following statement:

monthname = WorksheetFunction.Text(DateSerial(1900, monthnum, 1), "mmmm")

It returned the English month names.

My Windows language setting is right (Hungarian),
=Szöveg(Dátum(1900; monthnum; 1); "hhhh")
which is Hungarian translation of
=Text(Date(1900, monthnum, 1), "mmmm")
in my Excel 2000 returns the right Hungarian month names.

How can I get Hungarian month names in VBA?

Thanks,
Stefi
 
R

Ron Rosenfeld

Hi All,

I wanted to get the Hungarian name of months in VBA in my Hungarian version
with the following statement:

monthname = WorksheetFunction.Text(DateSerial(1900, monthnum, 1), "mmmm")

It returned the English month names.

My Windows language setting is right (Hungarian),
=Szöveg(Dátum(1900; monthnum; 1); "hhhh")
which is Hungarian translation of
=Text(Date(1900, monthnum, 1), "mmmm")
in my Excel 2000 returns the right Hungarian month names.

How can I get Hungarian month names in VBA?

Thanks,
Stefi

Are these correct?

január
február
március
április
május
június
július
augusztus
szeptember
október
november
december

If so, try using the VBA Format function.

I generated the above using my US version of excel, with the Windows regional
setting set to Hungarian, and the following code:

---------------------
Sub foo()
Dim monthnum As Integer

For monthnum = 1 To 12
Debug.Print Format(DateSerial(2005, monthnum, 1), "mmmm")
Next monthnum

End Sub
---------------------

The Format function is supposed to be locale aware. I don't know why the
worksheetfunction.text doesn't work.


--ron
 
S

Stefi

Thanks Ron, it works, but it's not clear for me, why does format code "mmmm"
have different meanings in Text and Format functions?

Regards,
Stefi


„Ron Rosenfeld†ezt írta:
 
R

Ron Rosenfeld

Thanks Ron, it works, but it's not clear for me, why does format code "mmmm"
have different meanings in Text and Format functions?

Regards,
Stefi

VBA is said to be very US-centric. Excel and VBA are really two different
programs. And I don't know enough about internationally compliant coding to be
able to answer your question.

I don't understand is why the application.worksheetfunction.text, when used in
VBA with the "hhhh" coding, (on a machine with Hungarian regional settings)
doesn't work in VBA.


--ron
 
S

Stefi

As far as I experienced there are inconsistencies in the way VBA coding is
adjusted to regional settings, e.g. if one records a formula-entering macro
in Hungarian, say
=SZÖVEG(MA();"hhhh")
the VBA code result will be
ActiveCell.FormulaR1C1 = "=TEXT(TODAY(),""hhhh"")"
where the function names are translated but "hhhh" coding remains Hungarian.

Never mind, I'm glad about that you found the right path in this jungle!

Regards,
Stefi

„Ron Rosenfeld†ezt írta:
 
R

Ron Rosenfeld

As far as I experienced there are inconsistencies in the way VBA coding is
adjusted to regional settings, e.g. if one records a formula-entering macro
in Hungarian, say
=SZÖVEG(MA();"hhhh")
the VBA code result will be
ActiveCell.FormulaR1C1 = "=TEXT(TODAY(),""hhhh"")"
where the function names are translated but "hhhh" coding remains Hungarian.

Never mind, I'm glad about that you found the right path in this jungle!

Regards,
Stefi


"Onward through the fog"
--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top