Changing YYYYMMDD to MM/DD/YYYY

前端 未结 5 1978
盖世英雄少女心
盖世英雄少女心 2020-12-02 03:09

So I have a date that is 20170529 but whenever I try to format it to a date, the cell just becomes #########. So normally, that means the column width is too small, but even

相关标签:
5条回答
  • 2020-12-02 03:48

    from format cell choose from category choose date and choose which type you want

    0 讨论(0)
  • 2020-12-02 03:50

    Select the cells you wish to fix and run this short macro:

    Sub INeedADate()
        Dim r As Range
        For Each r In Selection
            v = r.Text
            If Len(v) = 8 Then
                r.Clear
                r.NumberFormat = "mm/dd/yyyy"
                r.Value = DateSerial(Left(v, 4), Mid(v, 5, 2), Right(v, 2))
            End If
        Next r
    End Sub
    
    0 讨论(0)
  • 2020-12-02 03:51

    A quick method would be Data, Text-to-Columns, Fixed Width, Date: YMD, Finish. The following is for all intents and purposes in real-time.

    Shouldn't take too much to record that into a sub procedure.

    0 讨论(0)
  • 2020-12-02 04:01
    =DATEVALUE(TEXT(A1,"0000\/00\/00"))
    

    and format the result as a date

    0 讨论(0)
  • 2020-12-02 04:02

    I had the same problem. I used "Gary's Student's" answer. You have to press ALT+F11 and just copy and paste, then close that window. Then you select the cells you want to change, go to VIEW tab, on the far right is macros, hit view macros and select the one that says "INeedADate"

    0 讨论(0)
提交回复
热议问题