我想在今天的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
Run Code Online (Sandbox Code Playgroud)
我不确定哪里出了问题,有人可以帮忙吗?如果今天的日期是2017年5月15日,我的预期产量是5个月和2017年.