+ Reply to Thread
Results 1 to 7 of 7

Macro to change date format

  1. #1
    Registered User
    Join Date
    01-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Macro to change date format

    Hello Excel Friends,

    I've been searching and trying to figure this out in Excel all day, and I just can't get what I need! So I hope you guys can help me figure it out.

    Basically, I've got a column with a date, but it's not in a typical date format. I need a line in my macro to convert this to a typical date format so I can sort oldest to newest.

    I've attached a sheet with "CURRENT" and "DESIRED" formats. Any help would be much appreciated, as I've got 100k+ columns to convert!

    date.xlsx

    THANKS!!

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Macro to change date format

    Why not use formula?

    =TEXT(LEFT(A2,FIND("+",A2)-1), "mm/dd/yyyy") &" " &TEXT(ROUNDUP(LEFT(A2,FIND("+",A2)-1),3),"hh:mm") and drag it down

  3. #3
    Registered User
    Join Date
    01-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Macro to change date format

    Quote Originally Posted by JieJenn View Post
    Why not use formula?

    =TEXT(LEFT(A2,FIND("+",A2)-1), "mm/dd/yyyy") &" " &TEXT(ROUNDUP(LEFT(A2,FIND("+",A2)-1),3),"hh:mm") and drag it down
    Thanks for reply. However, that formula ends up giving me the year as 2013 for all, when it could be 2009, 2010, 2011, or 2012. A macro would be best, as I'm building this into a large process. However, I'm new to macros, so I'm not exactly sure what is best.

    Thanks!

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Macro to change date format

    Non VBA solution (a part off)

    See the attached file.

    I used text to column to separate the data.

    I used VLookup to change the month.

    After that I combined the data and changed the format in dd-mm-yyyy

    The time can also be added in the formula (if wanted).

    You can copy paste special to get the data and delete the columns A -F.

    Of course you can record the manual actions to get the VBA code.
    Attached Files Attached Files
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,051

    Re: Macro to change date format

    Im not sure about a macro to do this, but the following foemula will give you what you want...

    =DATE(VALUE(RIGHT(A2,4)),MONTH(DATEVALUE(LEFT(A2,15))),DAY(DATEVALUE(LEFT(A2,15))))+TIMEVALUE(MID(A2,8,8))
    copied down

    format custom m/d/yyyy h:mm
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Macro to change date format

    Borrowing the formula from post #5, For a macro, let me know how this works for you...

    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 01-21-2013 at 06:54 PM.
    HTH
    Regards, Jeff

  7. #7
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    872

    Re: Macro to change date format

    In The Netherlands it looks to me like this.
    I changed the formule into this.

    I do not know if the language matters.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Harry.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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