Solved

Convert Date to French on button click

Posted on 2011-02-15
3
359 Views
Last Modified: 2012-05-11
Hi all, I have a range that points to a cell that contains a Date. The range is called Period_End_Date, I have a button that switches the language from English to French and vice versa. I need to be able to change the date format to French / English on the fly, can someone show me how to do that? My button code is below.
Public Sub LangGetSet(source As Integer)
 'scroll through Language sheet and check against ID passed in
    If source = 1 Then
        If language = "English" Then
            language = "French"
        'set date format of Period_End_Date to French (i.e. 20 Mai 2011)

        ElseIf language = "French" Then
            language = "English"
        'set date format of Period_End_Date to English (i.e 20 May 2011)
        End If
    End If
End Sub

Open in new window

0
Comment
Question by:boukaka
3 Comments
 
LVL 10

Expert Comment

by:cdebel
ID: 34902342
What do you mean by "On the fly"?  Without pressing the button?

You could trap a worksheet_change event, and check if the target correspond to your range.  If it correspond, then you need to know in which language you are displaying the date at the moment...
0
 
LVL 8

Accepted Solution

by:
wchh earned 500 total points
ID: 34902710
Try macro below
Public Sub LangGetSet(source As Integer)
 'scroll through Language sheet and check against ID passed in
    If source = 1 Then
        Range("A:A").Select 'Your date range
        If Selection.NumberFormat = "[$-809]d-mmm-yyyy;@" Then 'UK
            Selection.NumberFormat = "[$-40C]d-mmm-yyyy;@"  'French
        'set date format of Period_End_Date to French (i.e. 20 Mai 2011)
        Else
            Selection.NumberFormat = "[$-809]d-mmm-yyyy;@"
        'set date format of Period_End_Date to English (i.e 20 May 2011)
        End If
    End If
End Sub

Open in new window

0
 

Author Closing Comment

by:boukaka
ID: 34906436
Thanks so much, this works beautifully.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

939 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now