MWill
MWill

Reputation: 11

Excel Argument Not Optional

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

Answers (1)

Dportology
Dportology

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

Related Questions