【发布时间】:2015-06-13 14:33:09
【问题描述】:
我正在尝试格式化 excel 表中的列,其中常规格式日期时间到日期选项不起作用,因为我从 clear quest 中导出了 excel 中的数据。我需要 mm/dd/yyyy 格式的日期列,还有一个可以执行此操作的 VB 脚本。
【问题讨论】:
我正在尝试格式化 excel 表中的列,其中常规格式日期时间到日期选项不起作用,因为我从 clear quest 中导出了 excel 中的数据。我需要 mm/dd/yyyy 格式的日期列,还有一个可以执行此操作的 VB 脚本。
【问题讨论】:
Sub DateFormat()
Range("C2:C64").NumberFormat = "mm/dd/yyyy"
End Sub
【讨论】:
根据这篇文章:Excel VBA date formats
Function CellContentCanBeInterpretedAsADate(cell As Range) As Boolean
Dim d As Date
On Error Resume Next
d = CDate(cell.Value)
If Err.Number <> 0 Then
CellContentCanBeInterpretedAsADate = False
Else
CellContentCanBeInterpretedAsADate = True
End If
On Error GoTo 0
End Function
【讨论】: