Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Convert Date to French on button click

Posted on 2011-02-15
3
Medium Priority
?
365 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:Christian de Bellefeuille
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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
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…

718 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