Reputation: 11
Hey I am creating a form that has multiple buttons that trigger different subroutines. The first code works by for the second code
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
I get a Argument not optional
compile error. Any Suggestions?
Upvotes: 0
Views: 357
Reputation: 808
Here you go:
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
My guess is that you meant to declare ThisYear as an Integer, not an Interior, and in your ActiveWorkbook.SaveAs line, you refer to ThisMonth as simply Month
Upvotes: 2