+ Reply to Thread
Results 1 to 3 of 3

VBA code swapping date formats??

Hybrid View

  1. #1
    Registered User
    Join Date
    10-22-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    3

    VBA code swapping date formats??

    Hi all, new here, and need some help.

    I have a userform that I'm trying to autofill with the current date on activate.

    Currently calling the date from another sheet, (where its set to =TODAY(), and the formatting set to dd-mmm-yy)
    BUT- when the userform opens, the textbox displays the date as mm/dd/yy, which means the months and days are back to front.
    I'd be happy if I could get it to show up in the dd-mmm-yy format.

    Here is the code I am using:

    Private Sub UserForm_Activate()
    
    TextBox1.Value = Worksheets("Data").Cells(3, 2)
    TextBox1.Value = Format(TextBox1.Value, "dd-mmm-yy")
    Can anyone shed light on this, as I am stumped. In the UK, and PC set to English date format (dd/mm/yyyy)

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: VBA code swapping date formats??

    Use the Text property of the cell.
    Textbox1.Vlaue = Worksheets("Data").Cells(3,2).Text

  3. #3
    Registered User
    Join Date
    10-22-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA code swapping date formats??

    Thank Norie, such a simple fix, but works perfectly for my needs.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1