Solved

Convert Date to French on button click

Posted on 2011-02-15
3
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

751 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