Excel参数不可选

时间:2015-08-26 19:26:28

标签: excel vba

嘿我正在创建一个具有多个按钮的表单,这些按钮会触发不同的子程序。第一个代码用于第二个代码

Sub LateReports_Click()
    Dim ThisYear As Interior
    Dim ThisMonth As String

' Create a new workbook for Late Tools in the current year and month folder
ThisYear = Year(Now())
ThisMonth = MonthName(Now())
Workbooks.Add

ActiveWorkbook.SaveAs Filename:="R:\Tool Calibration\" & ThisYear & "\" & ThisMonth & "\Late_Tools_" & Month & ".xls"

End Sub

我收到Argument not optional编译错误。有什么建议吗?

1 个答案:

答案 0 :(得分:2)

你走了:

Sub LateReports_Click()
    Dim ThisYear As Integer
    Dim ThisMonth As String

' Create a new workbook for Late Tools in the current year and month folder
ThisYear = Year(Now())
ThisMonth = MonthName(Now())
Workbooks.Add

ActiveWorkbook.SaveAs Filename:="R:\Tool Calibration\" & ThisYear & "\" & ThisMonth & "\Late_Tools_" & ThisMonth & ".xls"

End Sub

我的猜测是你的意思是将ThisYear声明为整数而不是内部,而在你的ActiveWorkbook.SaveAs行中,你只需将ThisMonth称为月