为什么我在 Excel VBA 中得到的是数字而不是日期?

问题描述 投票:0回答:1

这是代码:

Function CurrentDate() As Date
CurrentDate = Date
End Function

但是在 Excel 工作表中我得到 45418enter image description here

excel vba
1个回答
0
投票

将单元格格式设置为日期即可。

Excel 将任何日期存储为从 1900 年 1 月 1 日开始的天数。这样做是为了让您可以使用日期进行计算。 任何早于该日期的日期都存储为纯文本。

© www.soinside.com 2019 - 2024. All rights reserved.