小编Unu*_*ill的帖子

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
Run Code Online (Sandbox Code Playgroud)

我不确定哪里出了问题,有人可以帮忙吗?如果今天的日期是2017年5月15日,我的预期产量是5个月和2017年.

excel vba

1
推荐指数
2
解决办法
3万
查看次数

标签 统计

excel ×1

vba ×1