• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Display month name from english to portuguese in calendar Example

S P P

Member
Display month name from english to portuguese in calendar Example
 

Attachments

  • Win10ExcelCal.xlsm
    77 KB · Views: 9
Excel may be able to translate month names from one language to another—it's impressively smart—but if so, I don't know how it works. If you want a VBA program to do it, I'd probably create a collection that contains both sets of month names, and use that for translation. Maybe something like this:
Code:
' Initialize the collection of month names.
Set Months = New Collection
Months.Add "Fev", "Feb"
Months.Add "Abr", "Apr"
Months.Add "Mai", "May"
Months.Add "Ago", "Aug"
Months.Add "Set", "Sep"
Months.Add "Out", "Oct"
Months.Add "Dez", "Dec"

' Later on, translate the English month name to Portuguese.
If Not Exists(Months, EngMon, PorMon) then PorMon = EngMon
The Exists function is not one that comes with Excel or VBA, nor is it a method that Collections offer; I had to write it myself, but I use it constantly. It searches Arg1 for the collection key Arg2 and returns True or False. The optional Arg3 is set to the item from the collection if the item exists, that is, if Exists returns True. In my version there's also a fourth optional argument Arg4 that is placed in Arg3 if the item isn't found, but maybe that gets too complicated; anyway the above will work, if you write the Exists function.

If you don't care to write Exists (and believe me it's handy!), you can just put all twelve months in the Months collection. Then the only way your program will get confused is if you feed it an invalid English month, like "mar" or "March" or something.
 
Well, it wasn't an entire program; I was just showing you, in a general way, how the code could be made to work. I left it to you to insert it into your program in the right place, and to adapt it as needed to make it work with the statements you've already written. I'm teaching you to fish, you see, not writing the program for you.

This requires that you look at the bits of code that I suggested, and understand how they work. At that point you should be able to adapt it yourself. But feel free to ask specific questions, if part of it confuses you.
 
I managed to make the modification, but something is not working can you help me
 

Attachments

  • Win10ExcelCal-modified.xlsm
    82.6 KB · Views: 4
S P P
# You should able to give some hints ... instead of something is not working
# Your file needs Windows ... I do not use
# Your file uses ActiveX-components ... I do not use ...
# I quick check some part of Your code
... try to modify below part ... maybe after that something will work better ... eg JUL
Code:
' modify in CalendarClass
            Select Case CommandButtonEvents.Caption
                Case "JAN": CurMonth = 1
                Case "FEB", "FEV": CurMonth = 2
                Case "MAR": CurMonth = 3
                Case "APR", "ABR": CurMonth = 4
                Case "MAY", "MAI": CurMonth = 5
                Case "JUN": CurMonth = 6
                Case "JUL": CurMonth = 7
                Case "AUG", "AGO": CurMonth = 8
                Case "SEP", "SET": CurMonth = 9
                Case "OCT", "OUT": CurMonth = 10
                Case "NOV": CurMonth = 11
                Case "DEC", "DEZ": CurMonth = 12
            End Select
 
S P P
# You should able to give some hints ... instead of something is not working
...
and that modification should do anyway
 
After 10 posts it is mentioned that the code should be triggered when selecting a cell. Easiest is to invoke with a double click.
 
SPP, do you know how to use the VB Editor to step through your program one statement at a time, and pause wherever you want to see what the value of any variable is? Well worth while; it makes debugging very easy. Well, comparatively easy.
 
When clicking on month and year, the months are visible, when selecting the month, the calendar of the selected month is not displayed.
 
Back
Top