我試圖獲得今天的VBA日期的年份和月份,我曾嘗試和下面是我的代碼:VBA-獲取月份和年份從今天日期
Sub automation()
Dim wsheet As Worksheet
Dim month As Integer
Dim year As Integer
Set wsheet = Application.Workbooks("try").Worksheets("try")
month = Application.WorksheetFunction.month(Date)
year = Application.WorksheetFunction.year(Date)
End Sub
我不知道在哪裏出錯了,誰能幫忙? 如果今天的日期是2017年5月15日,我的預期產出爲5月份和2017年。謝謝!
'Month'和'年'是'VBA.DateTime'模塊中的函數,不保留;-) –
@ Mat'sMug - 謝謝,編輯。 – Vityata