Excel Date Formatting

后端 未结 5 1934
攒了一身酷
攒了一身酷 2020-12-06 16:19

I have a large imported csv file containing American Dates in a column. I want to change these dates to UK format (dd/mm/yyyy) using a code. The problem is the

5条回答
  •  不思量自难忘°
    2020-12-06 16:57

    Oddly, to do this you need to convert one column of text to one column of text.

    Select the column containing your dates: mm/dd/yyyy

    • Under Data, Select Text to Columns
    • Select Fixed Width
    • Next
    • Set the column width divider after the year (yyyy)
    • In column data format
    • Drop down select mm/dd/yyyy (the source format)
    • Select Destination
    • Finish

    The source data will transform to the date format of your system.

    Sub USUKDateFormat()
    
        ' USUKDateFormat Macro
    
        Selection.TextToColumns Destination:=ActiveCell.Offset(0, 2).Range("A1"), _
            DataType:=xlFixedWidth, OtherChar:="/", FieldInfo:=Array(Array(0, 4), Array _
            (10, 1)) 
    End Sub 
    

提交回复
热议问题