Convert 'yyyymmdd hhmmss' to 'mm/dd/yy hh:mm'

前端 未结 3 619
眼角桃花
眼角桃花 2021-01-22 02:33

I have a row of data (Cell A3 and down) that contains a Unix timestamp in yyyymmdd hhmmss format that I\'m trying to convert to mm/dd/yy hh:mm format <

3条回答
  •  無奈伤痛
    2021-01-22 02:54

    Try this:

    Sub Kyle()
      Dim cell As Range
    
      ThisWorkbook.Activate
    
      For Each cell In Range("A2", Cells(Rows.Count, "A").End(xlUp))
        If cell.Value Like "######## ######" Then
          cell.Value = CDate(Format(cell.Value, "@@@@-@@-@@@@@:@@:@@"))
        End If
      Next cell
    End Sub
    

    Then format the column however you prefer.

    For me, that converts

    20150904 213613
    20150124 194003
    20150404 163056
    20151220 100509
    20150510 213512

    to this:

    09/04/2015 21:36
    01/24/2015 19:40
    04/04/2015 16:30
    12/20/2015 10:05
    05/10/2015 21:35

提交回复
热议问题