+ Reply to Thread
Results 1 to 6 of 6

text to columns date error when using Macro

  1. #1
    Registered User
    Join Date
    02-27-2008
    Posts
    6

    text to columns date error when using Macro

    Hi all,

    I have recently come across a frustrating issue with Excel 2003 when using a macro to convert a large text field to columns.

    Part of the field includes a date format (d/mm/yyyy h:mm).

    Whilst recording the macro, it converts everything perfectly, including the date requirement.

    However, when I run the macro on a fresh set of text, it converts the text to columns, but some - not all - of the date fields swap the day and month numbers around (i.e. as in the US date display), whilst the remaining dates revert back to text.

    An extra catch is that the sheet reads the cells in the european date configuration, so the day becomes the month and the month becomes the day.

    e.g. 12th Jan 2009 - displayed as 12/1/2009 when working properly, becomes 1/12/2009 (1st December 2009) when the error occurs.

    So, my question....
    Why does the text to column conversion work when done manually but won't work as a macro?

    Does anyone know of a work around?

    Rgds
    Ant

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: text to columns date error when using Macro

    Perhaps you'll post the macro.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    02-27-2008
    Posts
    6

    Re: text to columns date error when using Macro

    Macro below...

    Please Login or Register  to view this content.
    Last edited by AntDingle; 02-02-2009 at 10:27 PM.

  4. #4
    Registered User
    Join Date
    02-27-2008
    Posts
    6

    Re: text to columns date error when using Macro

    Example of text I'm trying to convert to columns

    {"12/01/2009 15:50:01 (T8******):", "I have spoken to.....(this line goes on for 6000+ characters).


    Bit I need to keep is date and time reference and the T number - which is basically the last update time and user reference.

    This particular date format changes to 1/12/09 15:50:01 - but still reads in the european time style so becomes 1st Dec 2009.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: text to columns date error when using Macro

    Ant, please take a few minutes to read the forum rules, and then edit your post to add code tags.

    And post a sample workbook, if you would.

  6. #6
    Registered User
    Join Date
    02-27-2008
    Posts
    6

    Re: text to columns date error when using Macro

    Sorry - blonde moment there

    Attached (I hope) is a sample workbook with three lines of data (with commercially sensitive data removed).

    Sheet 1 shows the base data
    Sheet 2 shows the disired outcome of the macro
    Sheet 3 shows the actual outcome of the macro

    I hope this helps...

    Cheers
    Ant
    Attached Files Attached Files

+ 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