我有 vba 功能在我的工作表上拆分日期/时间 但是当它发现凌晨 0:00 时它会停止,我不知道如何解决这个问题
代码
Function extractDateTime(strTime As Date) As Variant
Dim arrD, d As String, t As Date
arrD = Split(strTime, " ")
d = arrD(0)
t = CDate(arrD(1) & " " & arrD(2))
extractDateTime = Array(d, t)
End Function
当它在 12:00:00 AM 找到日期/时间时的图片 函数不返回值 arrD(1) 和 arrD(2)
单元格值
最佳答案
始终将日期/时间处理为 日期,而不是文本,不是数字,没有异常(exception)。所以:
Public Function ExtractDateTime(Value As Date) As Variant
Dim d As Date
Dim t As Date
d = DateValue(Value)
t = TimeValue(Value)
ExtractDateTime = Array(d, t)
End Function
关于excel - 12 :00:00 AM 时拆分日期/时间不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69834602/