我有這個代碼
If IsDate(EndTime) = True Then
Worksheets("Control_File2").Range("D" & lrow2).Value = EndTime
Else
Worksheets("Control_File2").Range("D" & lrow2).Value = "Not Provided"
End If
目前結束時間=“25/08/2021 07:35:47.546”,但代碼總是進入“Else”條件。
為什么它不承認它是一個日期?
uj5u.com熱心網友回復:
正如 GSerg 指出的那樣,毫秒沒有被IsDate().
Function IsDate2(Value As Variant) As Boolean
Rem I added this line to escape empty strings
If Len(Value) = 0 Then Exit Function
IsDate2 = IsDate(Split(Value, ".")(0))
End Function
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/434846.html
標籤:vba
