使用VBA将"Wed Dec 02 24:00:00 GMT 2020"转换为02/12/2020



我想转换为"Wed Dec 02 24:00:00 GMT 2020";02/12/2020"使用VBA。

我创建了一个自定义函数。

Function Get_date(CellRef As String)
Dim Year_num As Integer, Month_name As String, Month_num As Integer, Date_num As Integer'''
Year_num = Right(CellRef, 4)
Month_name = Mid(CellRef, 5, 3)
Month_num = Month(DateValue(Month_name&("1")))
Date_num = Mid(CellRef, 9, 2)

Get_date = DateSerial(Year_num, Month_num, Date_num)

End Function

可以:

Get-date = CDate(Right(CellRef, 4) & Mid(CellRef, 4, 7))

相关内容

  • 没有找到相关文章

最新更新