分类：电脑/网络
问题：Excel2008怎样将2001
怎样将2001-5-8改写成2001-05-08形势好多一行很多改成年年年年-月月-日日
回答：用附件的自定义公式=dateF(A3)

前提是A3 里面要是XxxX-X-X 或XXXX-xx-x or xxxx-x-xx格式的阿 
Option Explicit

Function dateF(ByVal xx As String) As String
Dim i As String
Dim j As String
j = Right(xx, 2)

If Mid(xx, 7, 1) <> "-" Then
i = Left(xx, 7)
Else
i = Left(xx, 5)
i = i & "0" & Mid(xx, 6, 1)
End If

If Left(j, 1) <> "-" Then
i = i & "-" & j
Else
i = i & "-" & "0" & Right(j, 1)
End If

dateF = i
End Function