Sub test()
Dim m As Date, d As String
m = DateValue(Range("a1"))
d = Format(m, "mm/dd/yyyy")
MsgBox d
End Sub
答案 1 :(得分:1)
文本到列,固定宽度,下一步,MDY,完成。
在VBA中,
Option Explicit
Sub Macro4()
With Worksheets("sheet1").Columns(1)
.TextToColumns Destination:=.Cells(1), DataType:=xlFixedWidth, FieldInfo:=Array(0, 3)
.NumberFormat = "m/d/yyyy"
End With
End Sub