Saturday, 4 June 2016

VBA Macro to Convert Dates to MDY Format

Text to Columns Method for Dates Conversion to MDY Format
Sub Convert_Dates()

    CL = Selection.Column
    CLN = Split(Cells(, CL).Address, "$")(1)
    
    Selection.TextToColumns Destination:=Range(CLN & 1), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 2), TrailingMinusNumbers:=True

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

    Selection.TextToColumns Destination:=Range(CLN & 1), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 3), TrailingMinusNumbers:=True

End Sub

1 comment:

  1. Excellent materials in this site.
    These very useful for my vba project

    ReplyDelete

Follow Me by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts