+ Reply to Thread
Results 1 to 7 of 7

Date formats

  1. #1
    Registered User
    Join Date
    02-24-2016
    Location
    Glasgow
    MS-Off Ver
    2016
    Posts
    11

    Date formats

    Hi Everyone,

    I am capturing data from a csv file using VBA, and using it to populate an Excel 2003 workbook. The first column in the csv file contains dates, and these are being partially converted to American format. If the date is 06/10/15, it comes across as 10/06/15. On the other hand, if the date is 13/10/15, it stays the same. Does anyone know how to sort this?

  2. #2
    Registered User
    Join Date
    02-22-2016
    Location
    Harare, Zimbabwe
    MS-Off Ver
    2007 & 2010
    Posts
    71

    Re: Date formats

    What Date Format would you prefer in the sheet?

  3. #3
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Date formats

    Select the column of dates and then use Data | Text to Columns. On the third step of the wizard, click on the date option and choose the correct format, for example, DMY. Click Finish. Done.

  4. #4
    Registered User
    Join Date
    02-24-2016
    Location
    Glasgow
    MS-Off Ver
    2016
    Posts
    11

    Re: Date formats

    I would like the format dd/mm/yy. The main issue is that the date come across directly for any date after the 12th. i.e. Excel examines the whole field, and determines the format according to the cell value.

  5. #5
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Date formats

    Did you try what I suggested?

  6. #6
    Registered User
    Join Date
    02-24-2016
    Location
    Glasgow
    MS-Off Ver
    2016
    Posts
    11

    Re: Date formats

    Hi Invisible Man,

    Thanks for the reply. It doesn't affect the issue. I'll try to be more specific:
    I have a file in csv format, and the first column "A" holds date values in the format dd/mm/yyyy.
    When I open the file using Excel 2003 all values appear without alteration.
    When I open the file using VBA and the "Workbooks.open" method, then:
    If the date <= 12th of the month, then the day and month are transposed i.e. the date 11/06/2015 becomes 06/11/2015. Otherwise.the date comes across as is.

    In my view, the problem lies with the workbooks.open method. An alternative might be to treat the input file as a text file, but this brings its own problems that I won't bore you with.

  7. #7
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Date formats

    Just record a macro to use Text to columns as described. Then run that macro, or embed it into your existing code, as soon as the file is opened.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA:comboboxes to present same date in different formats...ADAPT WITH CHANGE IN DATE
    By AlexDobbin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-13-2015, 08:30 PM
  2. Date Formats
    By MPanter in forum Excel General
    Replies: 2
    Last Post: 12-07-2010, 09:26 AM
  3. US to UK Date Formats
    By reggie1000 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-22-2009, 10:49 AM
  4. Date formats
    By AndySuk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-12-2008, 05:26 AM
  5. date formats
    By Matt in forum Excel General
    Replies: 2
    Last Post: 05-17-2006, 02:55 AM
  6. Date formats
    By mohd21uk via OfficeKB.com in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 05-16-2006, 09:45 AM
  7. [SOLVED] Date formats
    By mohd21uk via OfficeKB.com in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 05-16-2006, 08:15 AM

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