Excel User Group
Microsoft Excel blogs, forums, files. Read, ask questions, provide answers.

Date Formatting Problem in VBA

Latest post Wed, May 27 2009 12:20 AM by Jan Karel Pieterse. 1 replies.
  • Tue, May 26 2009 6:47 AM

    Date Formatting Problem in VBA

    Hi there

    I have a problem with Day and Month switching round when I format a column of dates using 'Text to Columns' in VBA.  It only happens where the day value is equal to or less than 12 (so can be a month value).  The macro has been working for ages, but the source of the data has just changed and the problem has started.  It doesn't occur if I run the process manually though - only when I run the code.

    The code is as follows

    'Selection.TextToColumns Destination:=Range("M1"), DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
            Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
            :=Array(1, 4), TrailingMinusNumbers:=True

    Anyone help me out ??  Is it coming from the new data souce ?

    Steve

     

    • Post Points: 21
  • Wed, May 27 2009 12:20 AM In reply to

    Betreft: Date Formatting Problem in VBA

    Hi Steve,

     

    This is caused by the fact that VBA speaks American I guess. Record a macro whilst doin the TTC manually and specify the exact date sybtax instep 3 of the TTC wizard. spot the differnce in the code and modify accordingly.

    Regards, Jan Karel Pieterse www.jkp-ads.com
    • Post Points: 5
Page 1 of 1 (2 items) | RSS
Copyright Excel User Group and the relevant contributors, 2010. All Trade Marks acknowledged. This site is a peer-to-peer site and NOT affiliated in any way to Microsoft Corp. All rights reserved.