VBA Year 函数返回与指定日期的年份相对应的整数。
Year(日期)
使用 Year 函数从日期检索相关信息:
Sub YearExample1()
myDate = #10/30/2020#
MsgBox Year(myDate) '返回:2020
End Sub
此函数还接受文本格式的日期:
Sub YearExample2()
myDate = "30/10/2020"
MsgBox Year(myDate) '返回:2020
End Sub